Saturday, November 15, 2014

Accessing Servers by Hostname Instead of IP Address

Prerequisites: This guide was written for Mac OS X and Linux Ubuntu users.

If you're still SSH'ing into your servers by IP address, here's a tip that will make your life a whole lot easier. First, you'll need to store your server's IP address in your /etc/hosts file like so:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 localhost
0.0.0.0 server

In the above example, 0.0.0.0 would be replace by an actual IP address, and "server" would be the hostname of that server. You can name it whatever you want, really.

Now you can ssh with ssh user@server instead of ssh user@0.0.0.0 from here on.

No comments:

Post a Comment