Changing a host's IP address in /etc/hosts has effect to ping, but not for ssh
0
votes
1
answer
33
views
My host's IP address changes sometimes, I can't help on it. So, I change the entry in
/etc/hosts
:
192.168.1.106 myhost
I can *ping* it:
PING myhost (192.168.1.106): 56 data bytes
64 bytes from 192.168.1.106: icmp_seq=0 ttl=64 time=66.849 ms
64 bytes from 192.168.1.106: icmp_seq=1 ttl=64 time=7.315 ms
64 bytes from 192.168.1.106: icmp_seq=2 ttl=64 time=13.457 ms
I can simply *ssh* to it with IP address.
But I can not *ssh* with host name:
$ ssh -vvvv myhost
OpenSSH_9.9p2, LibreSSL 3.3.6
debug1: Reading configuration data /Users/ern0/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/ern0/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/ern0/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: channel_clear_timeouts: clearing
debug1: Connecting to myhost port 22.
ssh: Could not resolve hostname myhost: nodename nor servname provided, or not known
I found no useful information in verbose *ssh* output.
I may add entry in ~/.ssh/config
to specify the IP address, but I think, /etc/hosts
should do the job.
I am using latest MacOS:
$ uname -a
Darwin touchbar.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:48:46 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8103 arm64 arm Darwin
Does *ssh* have some hidden mechanism I don't know?
Asked by ern0
(111 rep)
Jul 30, 2025, 01:12 PM
Last activity: Jul 30, 2025, 02:18 PM
Last activity: Jul 30, 2025, 02:18 PM