Nov 10, 2018

How to configure multiple private keys to login to different servers

If you have two or more private keys for multiple servers and you wish to connect using multiple private keys, create ~/.ssh/config file, that contain following lines:


Host server1 server1.i88.ca
Hostname 88.88.88.88
User i88ca
IdentityFile /path1/server1.pem

#...

Host serverN serverN.i88.ca
Hostname 188.188.188.188
User root
IdentityFile /pathN/serverN.pem

In Host, first name is short name that can be used with ssh command, for example:

$ ssh server1