Short ssh alias to access to remote host via ssh

Often, when I want to access my remote DigitalOcean server I have to find out the IP address of it. It isn’t comfortable for me so I decided to create a short alias for this IP in /etc/hosts. Now, after I’ve just made an alias, it’s really more comfortable and faster to login to the remove server via ssh.

/ets/hosts

   localhost
       infous-desktop
    your_alias

Login via ssh using the alias

ssh 

UPDATE:

The another way to set the ssh alias is to edit the ~/.ssh/config file.

Host your_alias
Hostname 

Then to login just type:

ssh 

But there’s a shorter way. Again, edit ~/.ssh/config and set:

Host your_alias
Hostname 
User your_user

Now, you can login to your remote host via ssh like:

ssh your_alias

Thanks to everybody that commented this little note and suggested more elegant solutions!

3 Responses to “Short ssh alias to access to remote host via ssh”

  • d:

    You have much to learn. To refrain from editing system files, for one..

    A better solution may be:

    $HOME/.ssh/config:

    Host your_alias
    Hostname

  • Cold Night:

    You could also configure properly SSH. For example, in your ~/.ssh/config file :

    Host alias
    Hostname
    User youruser

    And then,

    ssh alias

    (and you can do ssh anotheruser, too.)

    :) .

  • Vacheslav:

    Cold Night and d, thanks for your solutions! :-)