If you are frequently using SSH to connect to several servers, with several permission files, and different usernames – then maybe a SSH Config file is for you. It tells SSH which settings and options to use when connecting to different servers.
To set this up, create a file called
~/.ssh/config
And add instructions. Here is a sample that might help.
Host ns?.redronin.com, ns?
User root
IdentityFile ~/.ssh/redronin.pem
Host red
User root
HostName red.redronin.com
Host ec2-1-2-3-4.compute-1.amazonaws.com, db-slave
User root
IdentityFile ~/.ssh/redronin-us-east.pem
HostName ec2-1-2-3-4.compute-1.amazonaws.com
Host *.ap-southeast-1.compute.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/redronin-ap-singapore.pem
Host *.us-west-1.compute.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/redronin-us-west.pem
Host *.compute-1.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/redronin-us-east.pem
You will notice I indented the options for ease of reading, but this is optional. The Host variable differentiates different servers. You can use * and ? and comma deliminate multiple options.
The most useful settings are
- User
- HostName
- IdentityFile
- Port
But there is a heap more http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&sektion=5