Sunday, August 10, 2025

macos – SSH via hostname to local server does not work

I installed a Proxmox server on the local home network which is running on 192.168.2.100 and I can successfully SSH to it from my MacBook (Sequoia 15.1.1 24B91) using IP address. However, I cannot SSH using hostname. I have updated my /private/etc/hosts file, however I can’t seem to SSH via hostname.

I can SSH using IP:

 ❯ ssh [email protected]
    [email protected]'s password:

Port is open:

❯ nc -zv 192.168.2.100 22
Connection to 192.168.2.100 port 22 [tcp/ssh] succeeded!

Hosts file:

❯ cat /private/etc/hosts
    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1   localhost
    255.255.255.255 broadcasthost
    ::1             localhost
    192.168.100.2   mylab.home.local mylab

Trying to resolve hostname does not work:

❯ host mylab
    Host mylab not found: 3(NXDOMAIN)

Trying to resolve hostname does not work:

❯ nslookup mylab

        Server:     2a02:a450:4599:0:ce58:30ff:redacted
        Address:    2a02:a450:4599:0:ce58:redacted:2400#53
    
    ** server can't find mylab: NXDOMAIN

When running ping, it does resolve hostname:

❯ ping mylab
    PING mylab.home.local (192.168.100.2): 56 data bytes
    Request timeout for icmp_seq 0
    Request timeout for icmp_seq 1
    ^C
    --- mylab.home.local ping statistics ---
    3 packets transmitted, 0 packets received, 100.0% packet loss

SSH using hostname does not work

❯ ssh -vvv root@mylab
    OpenSSH_9.8p1, LibreSSL 3.3.6
    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 *
    debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/redacted/.ssh/known_hosts'
    debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/redacted/.ssh/known_hosts2'
    debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
    debug3: channel_clear_timeouts: clearing
    debug1: Connecting to mylab port 22.
    ^C

What else can it be?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles