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).)

  • 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 :) – lofidevops 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

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

| improve this answer | |

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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