You want to create a ~/.ssh/config
file with the necessary entries. The equivalent of the -i
command line option is the IdentityFile
command in the configuration file.
Host my.domain.com
HostName other-name
User me
PreferredAuthentications publickey
Port 2222
IdentityFile /home/me/.ssh/other_keys/other_id_rsa
More info about the configuration file can be found in man ssh_config.
IMPORTANT NOTE: If you are to use many such keys, place them in a sub-directory otherwise you will get failures because ssh tries to login with all the keys found directly under ~/.ssh
. However, most servers will accept 3 to 5 attempts. More keys in the .ssh
folder and it is likely to fail many login attempts unless you use the -i
option or the configuration file.