Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: ssh: could not resolve hostname

  1. #1
    Join Date
    Oct 2007
    Location
    Croatia
    Beans
    71
    Distro
    Ubuntu Development Release

    ssh: could not resolve hostname

    On my local network i'm using dynamic ip adresses (dhcp)...and i'm using ssh. When i try to connect to a computer on my local network it only works when i type user and ip address (user@ip_address) but not when i type user and hostname (user@hostname). In terminal i get
    "ssh: Could not resolve hostname evelin@evelin-laptop: Name or service not known"
    Can anybody help me?

    And one more thing. On my router I looked on the dhcp server and there are hostnames...
    Last edited by bebox; March 19th, 2009 at 07:03 PM.

  2. #2
    Join Date
    Mar 2009
    Location
    United States
    Beans
    Hidden!
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: ssh: could not resolve hostname

    There is a difference between DHCP and DNS. If your local network router has a DNS built in you would need to tell ssh to use the DNS. That would be configured in /etc/ssh/ssh_config. Something similar to "UseDNS yes". remember you have to recycle the ssh daemon if you modify ssh_config.

    If there is not a DNS on your local network then you would have to set up aliases in your /etc/hostsfile so your client knew about what ip address was assigned to the other computer name.
    Cheers - Kryptikos

    --------
    This is Linux country...on a quiet night you can hear Windows reboot.

  3. #3
    Join Date
    Oct 2007
    Location
    Croatia
    Beans
    71
    Distro
    Ubuntu Development Release

    Re: ssh: could not resolve hostname

    i'm not using dns...the problem is that everytime the computer restarts it get's a diferent ip addres.so i don't know which computer is which.and when i scan with nmap i only see ip addresses and no hostnames so how should i know on which to connect.

    it doesn't detect hostnames.only ip's.

  4. #4
    Join Date
    Oct 2007
    Location
    Croatia
    Beans
    71
    Distro
    Ubuntu Development Release

    Re: ssh: could not resolve hostname

    please people...can anyone give me a hint.

  5. #5
    Join Date
    Sep 2008
    Location
    PA , US
    Beans
    154
    Distro
    Ubuntu Studio 9.04 Jaunty Jackalope

    Smile Re: ssh: could not resolve hostname

    I always make sure my machine has a reserved or static IP. Once I do that , port 22 is the default SSH port so do :

    Code:
    ssh user@ip_address
    Doing it via the hostname may work locally, but Ive never had trouble with using the ip address, unless you are typing the hostname improperly

    Type "hostname" into the Terminal window to get your full hostname.

    Hope this helps,

    Cheers!

    -Nano

  6. #6
    Join Date
    Oct 2007
    Location
    Croatia
    Beans
    71
    Distro
    Ubuntu Development Release

    Re: ssh: could not resolve hostname

    Quote Originally Posted by Nano_ext3 View Post
    I always make sure my machine has a reserved or static IP. Once I do that , port 22 is the default SSH port so do :

    Code:
    ssh user@ip_address
    Doing it via the hostname may work locally, but Ive never had trouble with using the ip address, unless you are typing the hostname improperly

    Type "hostname" into the Terminal window to get your full hostname.

    Hope this helps,

    Cheers!

    -Nano
    Nano thnxs for your reply...i appreciate that.
    When i use it with ip's it works but i want to use hostnames because of dhcp ip's change all the time.

    My router where dhcp server is setup recognizes host-names...but when i try to connect with shh via hostname to a computer i doesn't work. nmap also doesn't recognize hostnames...

    i still didn't figure out what the problem is.

  7. #7
    Join Date
    Nov 2008
    Beans
    482

    Re: ssh: could not resolve hostname

    With DNS names are mapped to IPs and this mapping is more or
    less static, so it (nearly) never changes.
    So whenever you boot your computers you will not only get a different
    IP, but also a different name!

    This is a known problem, e.g. connecting to your web server
    if your DSL provider changes your IP every x hours.
    One solution for this is DynDNS. With DynDNS the static map
    of DNS is replaced with a more dynamic map and every machine
    sends a message like "I'm machine xyz and my current IP is a.b.c.d".
    But you do not really want to run a DynDNS service inside your network !?

    The easiest way to fix this issue might be to use static IPs instead
    of DHCP.

    (I wonder what kind of "names" your router sees, e.g. if he
    maps names to MACs or ...)

  8. #8
    Join Date
    Feb 2008
    Beans
    1,031

    Re: ssh: could not resolve hostname

    On a lan there is no host name resolution on ubuntu unless you have a dns server set up, which most home lans do not.

    If you are in a heterogeneous network with windows boxes lurking arounf and are expecting those to work you need to look into using either a dns server or enabling netbios resoution.

    Alternatively use static ip's and add a the ips to resolv.conf on the appropriate pcs.

    One final suggestion is to try using hostname.local. That method should do the hostname resolution via avahi, which seems to work nicely in my setup where I have macs, xp boxes and ubuntu

  9. #9
    Join Date
    Oct 2007
    Location
    Croatia
    Beans
    71
    Distro
    Ubuntu Development Release

    Re: ssh: could not resolve hostname

    Quote Originally Posted by sedawk View Post
    With DNS names are mapped to IPs and this mapping is more or
    less static, so it (nearly) never changes.
    So whenever you boot your computers you will not only get a different
    IP, but also a different name!

    This is a known problem, e.g. connecting to your web server
    if your DSL provider changes your IP every x hours.
    One solution for this is DynDNS. With DynDNS the static map
    of DNS is replaced with a more dynamic map and every machine
    sends a message like "I'm machine xyz and my current IP is a.b.c.d".
    But you do not really want to run a DynDNS service inside your network !?

    The easiest way to fix this issue might be to use static IPs instead
    of DHCP.

    (I wonder what kind of "names" your router sees, e.g. if he
    maps names to MACs or ...)
    If DynDNS fixes my problem i want to use it.
    My router sees, e.g.:

    Dynamic Addresses:
    IP Address Host Names Type
    40.30.5.3 bebox-laptop Dynamic
    40.30.5.5 evelin-laptop Dynamic
    And now when i scan my network i can only see ip addresses and no hostnames. Does DNS service make hostnames visible to the local network? Or do i missunderstand how this works?

  10. #10
    Join Date
    May 2006
    Location
    Winchester MA, USA
    Beans
    9
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: ssh: could not resolve hostname

    First of all, I'm assuming this is all internal - laptop A needs to reach desktop B, both using IP's assigned by the router or something else inside the network. If you're trying to reach in through your router from work etc., you need a DynDNS service and it all gets more complicated.

    *** If you're only looking inside, forget DynDNS *** Dynamic DNS is not your friend either.


    Basically, you need something to map from hostname to IP. This is typically either DNS or /etc/hosts. Neither is done easily with random IP's (can be done, but probably not worth the effort on a home network).

    My router where dhcp server is setup recognizes host-names...but when i try to connect with shh via hostname to a computer i doesn't work. nmap also doesn't recognize hostnames...
    I'm guessing what you mean here is the DHCP server is configured to give a predictable address to particular clients (via MAC address, most likely)? If so, you're halfway there, but as kryptos said,
    If there is not a DNS on your local network then you would have to set up aliases in your /etc/hosts file so your client knew about what ip address was assigned to the other computer name.
    So configure a DNS server (on router or otherwise) or add the computers to /etc/hosts:

    Code:
    #IP  hostname [[alias1] [...]]
    127.0.0.1  localhost
    192.168.1.1  machine1.home machine1
    Obviously you'll need to supply your own hostnames and ips.

    Also: resolv.conf points to DNS servers, not any other machine. Avahi appears to be Apple-specific, so unless you already have it configured for a mac it's probably not going to help a ton.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •