SSH – How to Permanently Store Addresses

command linehostsssh

I have a few remote servers which I connect to through the terminal. The servers don't have a domain, only an IP address which is hard to remember when I got a few of them.

Is there a way to permanently store values in the terminal, so that I can do the following?

server1 = 111.222.111.222

And type commands like:

ssh root@server1

instead of:

ssh root@111.222.111.222

Best Answer

For SSH connections, you can create a user configuration file ~/.ssh/config and place the mappings there e.g.

Host server1
  Hostname      111.222.111.222

You can easily add other fields such as Port (for non-standard ports) and User (useful if your username on the remote system differs from that on the local system). See man ssh_config for full details.

Related Question