Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Let's say I just have an ip address for a server and I don't have a domain with it (it's just a database server, so it doesn't need a domain). I don't want to have to remember the ip address every time, so is there a way I could still use the syntax like ssh username@database or something?

share|improve this question

5 Answers 5

up vote 14 down vote accepted

If you only want the name for ssh and ssh only, you can add a name to your ssh config in ~/.ssh/config

As an example, your config file could look like this:

Host database
    HostName <real IP address or hostname here>
    User username

Then you can type ssh database on the command line and ssh will automatically do ssh username@ip.address for you.

share|improve this answer

Add an entry for it to /etc/hosts on the system you're ssh'ing from.

The syntax is hostname

This works on Linux and Mac. For windows, the file is c:\windows\system\drivers\etc\hosts

share|improve this answer

clients have 2 or 3 ways to associate a name with a IP address.

1) DNS, but that implies a hostname and a domain.

2) host file, you can add any name in the clients host file and then it will be used. Add the line ' database' in /etc/hosts to associate the name database with the address See http://en.wikipedia.org/wiki/Hosts_%28file%29 for more specific details and OS specific locations.

3) NIS, Solaris computers can use NIS to share hostnames for multiple clients.

share|improve this answer
Or LDAP. Or mDNS. Or any NSS-enabled mechanism. –  Ignacio Vazquez-Abrams Dec 21 '10 at 22:07

You need just to add the database name-IP mapping to your /etc/hosts file. The hosts file can be easily edited. You will find some entries there.

This name can be used for any connection not just SSH.

share|improve this answer

Create a DynDNS, it's free, in five minutes you can add a A record that points to your IP.

For example: create database1.dyndns.org as an A record pointing your ip
You can access from everywhere using:

ssh username@database1.dyndns.org

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.