Macos – ssh: Could not resolve hostname – High Sierra

macosmacos-highsierrassh

I'm supporting a coworker who recently upgraded his MacBook Pro to High Sierra from Sierra. He's trying to connect to one of our boxes in the field via ssh. The box in question has an IPv6 address.

The ~/.ssh/config file is empty and the ssh keys haven't changed. The /etc/ssh/ssh_config file is the default installed on the MBP. Dig works just fine and reports the proper IPv6 address of the box. Ping6 also works as expected. He can connect to our in-house git server, which is published via DNS with an IPv4 address, and push/pull without issue.

When I get him to ssh to the box, like so:

ssh user@hostname

The connection fails with:

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

Adding -vvvv to ssh produces the following output:

ssh -vvvv [hostname]
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to [hostname] port 22.
ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known

If he connects to the appliance using the IPv6 address, the connection succeeds and he can login.

Our DNS servers are properly configured and serving addresses as expected. I'm on an MBP with Sierra and I'm having no issues connecting. Also, our group all uses Macbooks of various vintages and OS flavors (no other High Sierra users) and, so far, he's the only one experiencing this issue.

EDIT: We tried the solution presented here. But, Apple's System Integrity Protection got in the way. I'm not about to turn it off at this point. I'd like to leave that as a last resort.

Best Answer

Here's a work around that helped in this case:

# install openssh from brew
brew install openssh

# /usr/local/sbin shouldn't be writable on High Sierra (by default), 
# so brew will fail to link the ssh binary

brew unlink openssh
ln -s /usr/local/Cellar/openssh/<version of openssh>/bin/ssh /usr/local/bin/ssh

That linked a version of ssh that's usable. My coworker is now able to connect as expected. Since there are now two versions of ssh on his mac, it's important to make sure that the openssh version installed via brew is found on the PATH first, eg.

PATH=/usr/local/bin:/usr/bin
Related Question