ssh: Could not resolve hostname [hostname]: nodena

2019-01-29 23:43发布

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 reason, this is proving to be impossible and I haven't the slightest clue why. When I try to ssh into my server with user@hostname, I get the error:

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

However, I can log into the server with,

ssh user@[local IP]

The server is a Raspberry Pi Model B running the latest distribution of Raspbian and the machine I am trying to connect to it with is a Macbook Pro running Mavericks. ssh was enabled on the Raspberry Pi when I set up Raspbian.

I have perused Stack Overflow for hours trying to see if anyone else had this problem and I have not found anything. Every ssh tutorial I find says that I should just be able to set it up on the remote machine and log in from anywhere using a hostname, and I have never had success with that.

11条回答
看我几分像从前
2楼-- · 2019-01-30 00:00

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.

查看更多
我只想做你的唯一
3楼-- · 2019-01-30 00:02

I had the same issue connecting to a remote machine. but I managed to login as below:

ssh -p 22 myName@hostname

or:

ssh -l myName -p 22 hostname
查看更多
Animai°情兽
4楼-- · 2019-01-30 00:11

It seems that some apps won't read symlinked /etc/hosts (on macOS at least), you need to hardlink it.

ln /path/to/hosts_file /etc/hosts

查看更多
时光不老,我们不散
5楼-- · 2019-01-30 00:17

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

查看更多
何必那么认真
6楼-- · 2019-01-30 00:18

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]
查看更多
【Aperson】
7楼-- · 2019-01-30 00:23

If you're on Mac, restarting the DNS responder fixed the issue for me.

sudo killall -HUP mDNSResponder
查看更多
登录 后发表回答