I just set up Ubuntu 12.04 Server on an old box laying around, connected to my router via ethernet. I set up openssh-server as instructed for remote access, but I cannot ssh into it from my laptop using the hostname.

Strangely though, I can ssh into it using the IP address. I would really like to fix this for the sake of convenience. I notice there are a few similar questions, but it seems all these people had some idea of what direction to go in to fix the problem, and were asking slightly more specific, technically-worded versions of my questions.

As a complete beginner to home networking, I would majorly appreciate if someone would tell me where to go from here.


2 Answers 2


Unless you configure hostnames in a central location, there's no way for your laptop to know the hostname you configured on the Ubuntu server.

So if when you installed the ubuntu server you named it "bonkers", it's understandable that on the laptop ssh bonkers will not do anything, as the laptop has no idea about that hostname.

Possible solutions:

  • On your laptop (you didn't say which OS it is running?) add a line in the /etc/hosts file for your Ubuntu server's IP address, something like this (use the actual IP from your Ubuntu server): ubuntu-server

    Then you can do ssh ubuntu-server and it should work. Note that the location of the hosts file depends on which OS your laptop has; I'm not sure where it is on Windows, for example.

  • Install the avahi-daemon package on your Ubuntu server. This utilizes the mDNS protocol to "advertise" its hostname on your local network. Once it's installed and running, you should be able to ssh ubuntu-server.local (notice the .local domain) and access the server. Again, if your laptop is running Windows, I can't say if it supports mDNS; I know Ubuntu (and any other Linux with avahi-daemon installed) and Mac OS X support it out of the box.

  • 1
    Setting up DNS is also an option, but it's a bit like using a hand grenade on a horsefly. (And not always possible).
    – jackweirdy
    Commented May 30, 2012 at 21:00

I had a similar problem and tried to solve it installing Avahi-daemon, just as roadmr suggested, but with apparently no result. Then I typed

host myhostname

and the terminal answered me:

myhostname.lan has address
Host myhostname.lan not found: 3(NXDOMAIN)

In the guest machine Iused as hostname myhostname.lan and it just worked. Until I am connected with DHCP. With assigned IP it does not work...

  • I have also found that the "host" command does not work with either host <system> or with host <system>.local even when avahi-daemon is installed. However, I was able to do a ssh <system>.local and it worked. So I suppose that the host command is not working with the mDNS/avahi stuff.
    – bgoodr
    Commented Nov 15, 2015 at 0:40

You must log in to answer this question.

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