Solved

Cannot ssh using domain name, only IP address

Posted on 2009-05-10
21
771 Views
Last Modified: 2012-05-06
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
Comment
Question by:Bloodrule
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 5
  • +2
21 Comments
 
LVL 2

Expert Comment

by:stany0
ID: 24347320
edit /etc/hosts file
format:
<IP> <HOSTNAME>.<DOMAIN> <ALIAS>
example:
127.0.0.1 localhost.localdomain localhost
0
 
LVL 12

Expert Comment

by:geowrian
ID: 24347323
What happens if you ping Desktop? Maybe it's not resolving the NetBIOS name.
0
 
LVL 12

Expert Comment

by:geowrian
ID: 24347331
@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
Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

 

Author Comment

by:Bloodrule
ID: 24347340
If I ping Desktop I get a "Unknown host Desktop" error.
0
 

Author Comment

by:Bloodrule
ID: 24347347
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
 
LVL 12

Expert Comment

by:geowrian
ID: 24347353
@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
 
LVL 12

Expert Comment

by:geowrian
ID: 24347357
@Bloodrule
If your workgroup/domain name was WORKGROUP:
192.168.0.10 Desktop.WORKGROUP Desktop
0
 

Author Comment

by:Bloodrule
ID: 24347377
Thanks for your helpful advice.  Here comes a dumb question:  How do I determine what my workgroup/domain name is?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24347379
is it available in dns? check your dns server
0
 
LVL 12

Expert Comment

by:geowrian
ID: 24347383
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
 

Author Comment

by:Bloodrule
ID: 24347390
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24347409
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
 

Author Comment

by:Bloodrule
ID: 24347599
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
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 200 total points
ID: 24347628
this means that your dns server is not resolving name to ip address. Can you put full domain name e.g.

Desktop.domain
0
 

Author Comment

by:Bloodrule
ID: 24347685
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24347712
Please put your domain name for the domain part. What OS are you running ?
0
 

Author Comment

by:Bloodrule
ID: 24347737
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24348251
can you show the content of the following files:

/etc/hosts
/etc/resolv.conf
0
 

Author Comment

by:Bloodrule
ID: 24349562
/etc/hosts:

127.0.0.1    localhost
192.168.0.10   Desktop


/etc/resolv.conf
nameserver    192.168.0.1
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24351241
can you show also /etc/nsswitch.conf
0
 
LVL 10

Accepted Solution

by:
lanboyo earned 300 total points
ID: 24359752
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question