Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

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

2 Answers 2

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 askubuntu.com/questions/2631/access-ubuntu-server-by-host-name/… –  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 ;-) –  queueoverflow 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 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
share|improve this answer

Your Answer

 
discard

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.