All HowTo's Cybersecurity Linux Ubuntu, Mint & Debian Linux

Specifying an SSH private key to use on the command line

You can specify which private key to use when issuing the Linux “ssh” command. This allows you to use one of many different private keys depending on which server(s) you’re connecting to.

ssh -l agix example1.agix.local -i id_rsa.exmaple1 -v

The above assumes that you have a private key in the file “.ssh/id_rsa.server1”. The “-i” option allows you to specify the private key to use. The “-v” option forces the ssh command to be verbose. This allows you to see that it is in-fact using the key you specified.

TIP: The ssh private key (and the public key on the remote server) must have the following permissions:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/*