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

unkategorisch

Issue:

I encountered the following error when running :

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

However

ping j13ubu3

worked fine, as the IP address I had set in /etc/hosts was found and used correctly. The /etc/hosts entry that worked for ping looked like this:

1.2.3.4 j13ubu3

Solution:

After adding a longer hostname with dots in the /etc/hosts entry:

1.2.3.4 j13ubu3 j13ubu3.my.own.network

the

ssh j13ubu3

command started to work as expected. Looks like ssh does not like it if there is a simple non dotted host name in /etc/hosts.

At least under:

ProductName:        macOS
ProductVersion:        14.5
BuildVersion:        23F79

OpenSSH_9.6p1, LibreSSL 3.3.6

that was the case today.