0

I setup a Ubuntu instance and I am trying to access from a windows system it via SSH with PuTTy. I can SSH with the IP address but I am unable to do so with the hostname.

I checked the /etc/hosts file on the Ubuntu server and it has the IP address and the hostname -

127.0.0.1       localhost
172.xx.xx.xx7   riz-7.xxxxxxxx.NET   riz-7

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

When I try to SSH with the hostname I get this error-

Unable to to open connection to riz-7. Host does not exist

What can be the reason? I was able to SSH with hostname earlier but not anymore.

| improve this question | | | | |
  • 1
    In the question you should strictly and explicitly distinguish the SSH client from the server, if only to avoid reader's confusion. E.g. Ubuntu is the server (because you're trying to access it). The hosts file is relevant on the client but I'm not sure you're aware of it; nor which hosts file you posted. I assume you posted the client's file. It's /etc/hosts, so the client is Unix/Linux as well, right? So you're using PuTTY for Linux, right? The question should be clear about all of these, please edit. What happens if you just ssh riz-7? (i.e. in a terminal, no PuTTY). – Kamil Maciorowski Mar 18 at 8:25
  • I am trying to reach Ubuntu server from a Windows system via PuTTy(SSH). When I try to SSH with the IP I am able to, but not with the hostname. When I do SSH riz-7 I get - "ssh: Could not resolve hostname riz-7: No such host is known." – Seeker90 Mar 18 at 9:25
4

You also need to update your hostnames in /etc/hosts in your client machine.

| improve this answer | | | | |
1

The following are required to access devices via their local hostname:

  1. Router's local domain name must be set (for example: .local)
    • Login to router's WebUI > Generally found under router's System settings
  2. Static IP must be set on the router for the device to be accessed via hostname.local
    • Router's WebUI > Generally found under Network settings
  3. OS' local domain must be set to router's local domain

    1. Windows: Workgroup name is Windows' local domain
      sysdm.cpl > Computer Name - Change... > Workgroup > OK > Reboot
    2. BSD/Linux: Varies by distro
      google: "distro name" change "local domain name"
  4. hosts file entry for the device to be accessed via hostname.local

    # Windows  : C:\Windows\System32\drivers\etc\hosts
    # BSD/Linux: /etc/hosts (can vary by DNS program being used)
    
      192.168.1.10       hostname         hostname.local
    

To access the device: hostname.local

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.