You are here: Saotn.org » GNU Linux » Ssh shorthand name for hostnames

Ssh shorthand name for hostnames

How to use shorthand names for hostnames with ssh? You don’t always want to type in a complete host name when using ssh to remote hosts. Here is how to configure and use shorthand hostnames with ssh.

GNU Bash Logo

Configure shortened names for hosts for use with ssh

If you want to configure shortened names for your servers & hosts for use with SSH, follow the next steps:

Open up your .ssh/config file:

vi ~/.ssh/config
Code language: Bash (bash)

and add the following:

Host your_short_name HostName server.on.the.web User user_to_user
Code language: Bash (bash)

Save the file and exit (:wq).

Now you can use ‘ssh your_short_name‘ instead of: ssh -l username this-is-my-long-hostname.example.com.

Pretty neat, right?! :-)

Protip: want to manually install OpenSSH in Windows Server? Or Tunnel RDP through ssh?

4 thoughts on “Ssh shorthand name for hostnames”

  1. This does not seem to work if the long form hostname relies of further configuration entries (with wildcards). e.g.:

    Host short
    HostName my.long.name

    Host *.name
    User myspecialusername

Leave a Reply

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