How to add an SSH key for a specific host

· 1 min read
How to add an SSH key for a specific host

Choose an SSH key instead of the default to connect to a specific remote server. ~ / .ssh / id_rsa

You have at least 2 options to choose the key used by ssh. for instance.~/.ssh/key1 [email protected]

Method 1 - Specify the key on the command line with the -issh option .

The command line to use is:

ssh -i ~/.ssh/key1 [email protected]

Method 2 - Use the ssh configuration file. This is useful when you don't have the option -iavailable, like when using git, rsync, or lftp.

You can add ~/.ssh/configthe following lines to your

Host ejemplo.com
  IdentityFile ~/.ssh/key1

This tells ssh that for the host ejemplo.com, use the file key~/.ssh/key1