• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 797
  • Last Modified:

Cannot ssh using domain name, only IP address

I have a small LAN running Ubuntu on several machines.  I can login using SSH from one to another, but only if I use the IP address.  Assume I am trying to ssh to a machine with an IP of 192.168.0.10 and a hostname of Desktop.

If I enter "ssh me@192.168.0.10" it logs me into Desktop to a prompt me@Desktop:~$

But if I try

"ssh me@Desktop" I get a message "ssh: Desktop: Name or service not known" even though I know that the hostname Desktop exists.

What am I missing?
0
Bloodrule
Asked:
Bloodrule
  • 8
  • 6
  • 5
  • +2
2 Solutions
 
stany0Commented:
edit /etc/hosts file
format:
<IP> <HOSTNAME>.<DOMAIN> <ALIAS>
example:
127.0.0.1 localhost.localdomain localhost
0
 
geowrianCommented:
What happens if you ping Desktop? Maybe it's not resolving the NetBIOS name.
0
 
geowrianCommented:
@stany0
Good idea. Keep in mind that's for *nix. Windows users will have to edit the hosts file in c:\Windows\system32\drivers\etc (assuming C is the Windows drive).

stany0's suggestion isn't a long-term fix; however, but does let us know if the problem is network based or application-based.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
BloodruleAuthor Commented:
If I ping Desktop I get a "Unknown host Desktop" error.
0
 
BloodruleAuthor Commented:
Would you mind telling me exactly what I might enter using your suggestion?

127.0.0.1 localhost.localdomain localhost

If the IP address of my machine is 192.168.0.10 (static) and  If the hostname is Desktop, what exactly should I enter using your example above as the template?
0
 
geowrianCommented:
@Bloodrule
That's your problem then...your computer isn't resolving "Desktop" to it's IP address. You can follow stany0's advice to make it work, but it will only work until it's IP changes. The long-term fix is to figure out why your computer isn't seeing it advertising it's name, or why the ssh server isn't advertising it, or if something is blocking the traffic.

Some question that can help identify the exact problem:
1) Can other computers on the same network get to it via "Desktop"?
2) Can you ping any computers on your network by their computer names?
3) Does the workgroup (or domain?) name on your computer match the workgroup name on the ssh server PC?
0
 
geowrianCommented:
@Bloodrule
If your workgroup/domain name was WORKGROUP:
192.168.0.10 Desktop.WORKGROUP Desktop
0
 
BloodruleAuthor Commented:
Thanks for your helpful advice.  Here comes a dumb question:  How do I determine what my workgroup/domain name is?
0
 
omarfaridCommented:
is it available in dns? check your dns server
0
 
geowrianCommented:
Windows:
Right-Click "My Computer"
Choose Properties
Choose "Computer Name" tab
Look where it says "Workgroup"

*nux:
hostname    (actually hostname -s gives just the workgroup)
0
 
BloodruleAuthor Commented:
Sorry but I don't know how to check my dns server?  Is that I command I issue in Linux or is it a setting in my router?  
0
 
omarfaridCommented:
from the system you are trying to ssh from, run

nslookup Desktop

and see if you get error message or resolved ip. What is your client OS?
0
 
BloodruleAuthor Commented:
When I run nslookup Desktop, I get this response:

Server:         192.168.0.1
Address:      192.168.0.1#53

** server can't find Desktop: NXDOMAIN

Not sure what to make of this.  Your help is appreciated.
0
 
omarfaridCommented:
this means that your dns server is not resolving name to ip address. Can you put full domain name e.g.

Desktop.domain
0
 
BloodruleAuthor Commented:
When I run nslookup Desktop.domain (I hope that's what you meant for me to try) I get exactly the same error message, namely

Server:         192.168.0.1
Address:      192.168.0.1#53

** server can't find Desktop: NXDOMAIN
0
 
omarfaridCommented:
Please put your domain name for the domain part. What OS are you running ?
0
 
BloodruleAuthor Commented:
I am running Ubuntu 8.10 on each machine.  I am not sure what you mean by "put your domain name for the domain part".  Sorry.
0
 
omarfaridCommented:
can you show the content of the following files:

/etc/hosts
/etc/resolv.conf
0
 
BloodruleAuthor Commented:
/etc/hosts:

127.0.0.1    localhost
192.168.0.10   Desktop


/etc/resolv.conf
nameserver    192.168.0.1
0
 
omarfaridCommented:
can you show also /etc/nsswitch.conf
0
 
lanboyoCommented:
It looks like you do not have a dns server serving dns for the local network. The .1 address is probably your internet router , which is proxying dns requests externally to whatever your isp assigns. If you want to get it working quickly, basically you will need to copy the contents of etc hosts into the other hosts file. Not the localhost or loopback part.

Windows uses netbios over tcp to resolve hostnames like this, this is not a great idea on *nix.

So if you really don't want to modify host files, you need to set up a local dns server, and you need to make dhcp aware of it, which may mean disabling the router's dhcp and setting up your own. Host files may be easier.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 8
  • 6
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now