For security reasons it's usually a good idea to use different SSH keys for each server or service you use, but it can be a little tedious if you have specify the key to use each time you connect.
So here is what you'd need to add to your ssh configuration file (usually at ~/.ssh/config
) to have it automatically pick the SSH key you want for each server.
If you have a SSH key named id_myserver
in your ssh directory add this to each server in your config file for which you want to use that specific key.
Host myserver
IdentityFile ~/.ssh/id_myserver
When you have several ssh keys in your config it looks something like this:
Host myserver
Hostname myserver.example.com
IdentityFile ~/.ssh/id_myserver
Host other_server
Hostname my_other_server.example.com
IdentityFile ~/.ssh/id_other_server