You probably already manage servers you often connect to inside the ~/.ssh/config
file. What is nice: you may define alias names for hosts so that you can say something like ssh foobar-staging
.
This is especially helpful for servers whose hostnames are hard to remember or who don't have a DNS record at all (and must be accessed via their IP address).
To achieve the above, you can define something like this in your ~/.ssh/config
:
Host foobar-staging
Hostname staging.example.com
Note that SSH will only match this for ssh foobar-staging
and not for ssh staging.example.com
. If you want that, add it to the Host
row separated by a space character -- this way you can also define multiple aliases.
Host foobar-staging staging.example.com my-playground
Hostname staging.example.com
Neat: The aliases will also be available in your bash as tab-completable arguments for the ssh
command.
Posted by Arne Hartherz to makandra dev (2011-05-30 09:28)