Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have all machines connecting to the internet through a wireless router (occasionally I plug a machine into the router via cable). I have installed the ssh package and can access one Ubuntu machine from another using, for example, "ssh". However, the local IP addresses change as machines are switched off and on and reconnect to the router, so I'd prefer to use "ssh machinename".

If I do type "ssh machinename", nothing happens, no error, no returning to the prompt.

What do I need to install/configure to access Ubuntu machines via their machine name?

(As a side note, I have Samba installed so I can access Windows machines on the same network. I have set name resolve order = lmhosts wins bcast host because I use OpenDNS, I'm not sure if this could affect Ubuntu networking. Name-based resolution works in both directions between Windows and Ubuntu (for example, connecting to an Ubuntu machine with WinSCP).)

share|improve this question
The simple way: use static addresses, and put them in /etc/hosts of each machine. – enzotib Aug 16 '11 at 6:47
enzotib: how do I "use static addresses"? would I need to configure something on the router? I found another answer relating to avahi which worked for me, is it possible this is doing what you describe automatically? feel free to add your answer to the mix :) – d3vid Aug 16 '11 at 6:58
The other answer is ok, so I don't elaborate anymore. – enzotib Aug 16 '11 at 7:28
possible duplicate of Access server by host name? – Jorge Castro Aug 16 '11 at 21:57
up vote 7 down vote accepted

First, make sure you have the Avahi daemon installed. (Should be installed by default on Ubuntu Desktop, but not on Server.)

sudo apt-get install avahi-daemon

Then to access them, add ".local" to the end of the name, for example

ssh machinename.local

I'm not sure if it's possible to remove the need to add .local

share|improve this answer
based on this answer and comments… – d3vid Aug 16 '11 at 6:54
I don't know how I had managed to miss that, but thank you very much! That makes things much easier for me :) – Jo-Erlend Schinstad Aug 16 '11 at 13:18
It is not installed on debian by default, so keep this in mind if you ever use debian ;-) – Martin Ueding Aug 16 '11 at 22:26

In case you only want to ssh into a machine by using a good to remember name you can also define a name in ~/.ssh/config by adding an entry like e.g.:

Host myremote
    HostName # IP or myremote.local name of remote
    Port 980 # Port to connect if different to defaults
    User <myloginname>

We are then able to ssh to myremote.local by simply typing:

ssh myremote
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.