Howto force ssh to use a specific private key?
With ssh -i <private key filename>
you can instruct ssh to use an extra private key to try authentication.
The documentation is not clear on how to explicitly use only that key.
Solution 1:
You can use the IdentitiesOnly option:
ssh -o "IdentitiesOnly=yes" -i <private key filename> <hostname>
Solution 2:
An alternative could be to generate a pair of keys using
ssh-keygen
and create a special configuration for the specified host and corresponding private key
Edit ~/.ssh/config
Host handy_server
HostName x.y.z.w
IdentityFile ~/.ssh/handy.pub
IdentitiesOnly yes
User userk
Port 22