Handling Multiple SSH Keys and Ports for Multiple Machines

You might have to deal with a lot of machines with different keys and ports. Here is a simple way to make that easier.

Edit / Create ssh config file.

vi ~yourUserName/.ssh/config

Put the information about your hosts into the config file:

 

Host server1.example.com

HostName server1.example.com
IdentityFile ~/.ssh/server1_rsa
User userName
Port xxxx
ServerAliveInterval 30
ServerAliveCountMax 120

PROMPT_COMMAND='echo -ne "33]0;${USER}@${HOSTNAME}: ${PWD}07"'

Now whenever you try to connect to that host, it will use the key, username and port defined in this config file.