How to access machines from alias rather than IP address using SSH

How to access machines from alias rather than IP address using SSH

Have a lot of IP addresses to save?
Difficult to remember or save in a file or write on a notepad?
Have to search and copy every time you need to access a machine?

No need to get worried,
Just open the file “/etc/hosts” on your machine.

$ nano /etc/hosts

Add the IP address in the next line to your machine’s localhost.

127.0.0.1 localhost
127.0.1.1 your-machine-name
0.0.0.0 alias-of-machine [optional-more-aliases] #replace 0.0.0.0 with IP
0.0.0.0 alias-of-machine [optional-more-aliases] #replace 0.0.0.0 with IP
[more-machines-on-same-pattern]
#The following lines are desirable for IPv6 capable hosts
##
##

and now just remember the aliases and access through ssh

$ ssh username@alias-of-machine
#alias of the machine you want to access

This alias can also be used in your web browser instead of IP.

 

Leave a Reply

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

%d bloggers like this: