My question my sound unclear so let me rephrase with an example.

When I try to ssh to my school, the format is as follows:

ssh <student_id>@<school>.com

From school, when I try to ssh home, the format is as follows:

ssh <computer_user_name>@<ip_address>

When I connect home I'm connecting with an ip address but when I connect to school, the school.com already corresponds to an IP, so I can just use school.com instead.

How do I get this "alias" for an IP so I can use that instead of writing my full IP out every time?

3 Answers 3


Use your SSH configuration file at ~/.ssh/config:

Host home
    User yourusername

Use your actual IP address. Be aware that most residential IP addresses are dynamic and subject to change, so you might want to use a DNS service like no-ip.org or dyndns.org to give yourself a domain name you can use in place of the IP address.

  • You could also set it in your /etc/hosts file like this: HostName . However I would only set it there if you are going to use that name mapping for more than just ssh. If you only need to map the IP for ssh the ssh config file is a better spot for it as your machine will parse the /etc/hosts file every time it does a name lookup and adding too much in there could add some latency to name resolutions.
    – jesse_b
    Jul 24, 2017 at 22:44
  • 1
    Also, the SSH config file supports wildcards, so you can do things like set your username for any host that matches *.yourschool.example.com.
    – DopeGhoti
    Jul 24, 2017 at 22:57
  • Okay so suppose I am bob@bob-ubuntu Then would my file be as follows: Host home bob bob-ubuntu ARandomName
    – K Split X
    Jul 24, 2017 at 23:40
  • If this is the case though, how do I know there isn't another bob@bob-ubuntu in the world, and so when I try to ssh, what if I connect to to them?
    – K Split X
    Jul 24, 2017 at 23:40

The "alias" you mention is a name for your machine, i.e. a host name. These "aliases" are managed globally by a network of domain name (DNS) servers that translate the names into IP addresses. In addition, locally in your machine, there is a file where you can define additional names that will not be available for other machines.

Then, you have two options:

1) If you want to define the "alias" (hostname) for all the users/machines in the Internet, you must

  • buy a domain name (e.g. k-split-x.com) and define the name or the names in a DNS server (e.g. home.k-split-x.com and other.k-split-x.com), or
  • use some service of dynamic DNS with a generic domain. For instance, Now-Dns offers names with the myiphost.com domain name.

If you are interested in a dynamic DNS solution, there are some free. You may use Google to find one. Now-Dns, NoIp and FreeDNS are some of them.

2) if you want to define the "alias" only for your machine, you must modify the "hosts" file.

  • In Windows, the hosts file is in c:\Windows\System32\Drivers\etc\hosts
  • In Unix, the file is in /etc/hosts
  • In Mac, it is in /private/etc/hosts

You may check information about how to change the file in many websites. I found an explanation in the Rackspace website


You can try to add a domain name in /etc/hosts file The format is

<home IP>  myhome.net

I always do that to save my time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .