ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known

前端 未结 15 2302
忘掉有多难
忘掉有多难 2020-12-12 09:34

I am trying to set up a VPN with a Raspberry Pi, and the first step is gaining the ability to ssh into the device from outside my local network. For whatever re

相关标签:
15条回答
  • 2020-12-12 10:12

    I needed to connect to remote Amazon server

    ssh -i ~/.ssh/test.pem -fN -L 5555:localhost:5678 ubuntu@hostname.com

    I was getting the following error.

    ssh: Could not resolve hostname <hostname.com>: nodename nor servname provided, or not known

    Solution For Mac OSX

    Pinging the host resolved the issue. I am using Mac OSX Seirra.

    ping hostname.com

    Now problem resolved. Able to connect to the server.

    Note: I tried this solution also. But it didn't work out. Then ping resolved the issue.

    0 讨论(0)
  • 2020-12-12 10:17

    I had the same problem: The address shown in Preferences -> Sharing -> Remote Login didn't work and I got a '... nodename nor servname provided, or not known'. However, when I manually edited the settings (in Preferences -> Sharing -> Remote Login -> edit) and enabled "Use dynamic global hostname", it suddenly worked.

    enter image description here

    enter image description here

    0 讨论(0)
  • 2020-12-12 10:17

    I had the same problem after testing Visual Studio Code with remote-ssh plugin. During the setup of the remote host the software did ask me where to store the config-file. I thought a good place is the '.ssh-folder' (Linux-system) as it was a ssh-remote configuration. It turned out to be a bad idea. The next day, after a new start of the computer I couldn't logon via ssh on the remote server. The error message was 'Could not resolve hostname:....... Name or service not known'. What happen was that the uninstall from VSC did not delete this config-file and of course it was than disturbing the usual process. An 'rm' later the problem was solved (I did delete this config-file).

    0 讨论(0)
  • 2020-12-12 10:18

    I had the same issue, which I was able to resolve by adding a .local to the host name, ala ssh user@hostname.local

    0 讨论(0)
  • 2020-12-12 10:20

    If you need access to your VPN from anywhere in the world you need to register a domain name and have it point to the public ip address of your VPN/network gateway. You could also use a Dynamic DNS service to connect a hostname to your public ip.

    If you only need to ssh from your Mac to your Raspberry inside your local network, do this: On your Mac, edit /etc/hosts. Assuming the Raspberry has hostname "berry" and ip "172.16.0.100", add one line:

    # ip           hostname
    172.16.0.100   berry
    

    Now: ssh user@berry should work.

    0 讨论(0)
  • 2020-12-12 10:20

    If your command is:

    $ ssh -p 1122  path/to/pemfile user@[hostip/hostname]
    

    You will also face the same error

    ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known
    

    when you miss the option -i /path/to/pemfile of ssh

    So Command should be:

    $ ssh -p 1122 -i path/to/pemfile user@[hostip/hostname]
    
    0 讨论(0)
提交回复
热议问题