Host alias for ssh

Solution 1:

Sometimes it is more convenient to have configuration files in our home directory. This avoids having to be root to edit files, and also they can be configured in a way that other users have no access to this data. In addition this configuration will be backed up with our home and also will "survive" an OS upgrade.

To do so we can make a ssh configuration file nano ~/.ssh/config where we can put in valuable information for a connection. A simple entry may have the following content:

Host myremote             # any name for the host
HostName 192.168.178.05   # IP, .local, or hostname if defined
User username             # your username
Port 22                   # port to listen

There are many other options including user and authentication you can give here (see manpage for ssh_config)

We then can simply issue the following to connect to 192.168.178.05 on port 22:

ssh myremote