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.

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/configCode language: Bash (bash)

and add the following:

Host your_short_name
HostName server.on.the.web
User user_to_userCode 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?! :-)

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

Jan Reilink

Hi, my name is Jan. I am not a hacker, coder, developer or guru. I am merely an application manager / systems administrator, doing my daily thing at Embrace - The Human Cloud. In the past I worked for clidn and Vevida. With over 20 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, websites & optimization. I blog at https://www.saotn.org.

4 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Daniel Schwen
16/01/2021 17:36

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

fr2632
11/01/2021 16:39

~/.ssh/config path does not exist anymore, please update your post!