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

share|improve this question
    
possible duplicate of How to reach a host in the same network by hostname? –  Jorge Castro Aug 11 '12 at 23:03
add comment

2 Answers

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

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

share|improve this answer
    
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 May 30 '12 at 21:00
add comment

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

share|improve this answer
add comment

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.