Ssh unable to resolve hostname in Ventura

I had the IPv4 address of the local machine in question in /etc/hosts. Ping was successful, but ssh was not able to resolve the host name until I added the IPv6 address to /etc/hosts as well. Is there a better way to deal with it?

iMac 21.5″, macOS 13.1

Posted on Feb 18, 2023 2:04 PM

Reply

Similar questions

7 replies

Feb 18, 2023 6:10 PM in response to LWarshawsky

I’m not sure what you’ve set up, and what the goal is here, as “the local machine” can be ambiguous in this context. The local machine name is (always) localhost, and an IPv4 address for the local computer is (always) 127.0.0.1. Or did you mean something else? Are you adding another host with some other address for some other computer on the local network?


And if it’s another computer on the local network, does it have mDNS / Bonjour running?


What do the following commands report for reachability?


scutil -r {IPv4 host name}


scutil -r {IPv4 host address}


I’ve found it best not to trust the dig and ping command with whatever might be in the local cache, and with /etc/hosts. The commands here are not integrated on a number of (any?) versions, and stuff doesn’t always get loaded or re-loaded from /etc/hosts as I’d prefer.

Feb 19, 2023 7:02 AM in response to LWarshawsky

LWarshawsky wrote:

It was, in fact, another machine in the house. Not localhost. Sorry for the ambiguity.

The SSH client is an iMac running Ventura.

The SSH server is a Raspberry Pi running Raspbian buster.

The nearest router is also the DHCP server for both machines. For purposes of privacy, the iMac is configured to use external DNS servers, rather than the router.


Local hosts best use local DNS services.


Trying to run split like this tends to get gnarly. And it’s more work.


All DNS traffic then goes to the local DNS server(s), and gets authoritatively answered there, or gets forwarded to the authoritative server from there as needed with the responses coming back through the same path, as per not al.


So long as the local DNS server is not accessible from the external network, there are no additional risks to privacy.


The /etc/hosts stuff is always “fun” to use on macOS, too. More so on portable Macs and such.

Feb 18, 2023 6:46 PM in response to BobHarris

BobHarris wrote:

I get the impression that “local machine” is another system in the house. Not localhost.

Then again I could be wrong.


Over the years, I’ve occasionally been surprised by the creativity of some IP networks and of some DNS configurations. And that the traditional command-line DNS tools aren’t integrated with the local DNS cache has caused problems on various occasions, too. This was all somewhat more common on macOS Server, where there could also be a local BIND DNS server in the mix.)

Feb 18, 2023 10:03 PM in response to BobHarris

It was, in fact, another machine in the house. Not localhost. Sorry for the ambiguity.


The SSH client is an iMac running Ventura.


The SSH server is a Raspberry Pi running Raspbian buster.


The nearest router is also the DHCP server for both machines. For purposes of privacy, the iMac is configured to use external DNS servers, rather than the router.


According to the Discovery app, the iMac advertises itself in Bonjour under _ssh._tcp. The pi does not.


The /etc/hosts entries for the pi share the same host name for IPv4 and IPv6.


$ scutil -r {name}
Reachable
$ scutil -r {IPv4 address}
Reachable,Directly Reachable Address


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Ssh unable to resolve hostname in Ventura

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.