If you have a lot of hosts that you maintain, keeping their IP adresses in mind or on the record if the IP addess somewhere else, and pasting them every time you wish to log in makes life hard. Even with one host. It’s much easyer to give it a name, like “myserver”, a port if you drive your sshd on an alternative port, and a default user to log in and then just type

ssh myhost

for an instant ssh to that host, without password (if you done the Part I of the article), or any other questions. This is called an ssh alias.

If you’ve already done the “passwordless login” from the article in Part I then you have the ~/.ssh directory created, otherwise you can create it or just do the Part I  before this.

We need to create / edit the ~/.ssh/config file and write our aliases in there, for examnple:

vi ~/.ssh/config

and write:

Host myserver
HostName <IP or URL to the remote server>
User <desired login user>
Port <the port that the remote sshd listens to, if not standard 22>

And done. If you have more than 1 host, just enter them below…

Then just do ssh myserver and you’ll be instantly logged into the remote host that is defined under it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.