6

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

4
  • The simple way: use static addresses, and put them in /etc/hosts of each machine.
    – enzotib
    Aug 16, 2011 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, 2011 at 6:58
  • The other answer is ok, so I don't elaborate anymore.
    – enzotib
    Aug 16, 2011 at 7:28
  • possible duplicate of Access server by host name? Aug 16, 2011 at 21:57

2 Answers 2

7

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

3
0

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 192.168.0.0 # 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .