Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

ssh from MacBookPro to Mac times out

I am trying to ssh from my MacBookPro to my Mac but it times out, both are on the same local area network. The same thing happens if I try to ssh from the Mac to the MacBookPro. However I can ssh to either via a RaspberryPi on the same network. I'm confused!


iMac 27″ 5K, macOS 12.6

Posted on Feb 4, 2023 9:58 AM

Reply
Question marked as Best reply

Posted on Feb 6, 2023 6:46 PM

The problem is almost certainly inside your router. You said it works when you connect to ethernet. You also said you are using a Raspberry Pi. And you are using ssh. Those are all things that people do when they hack around with things. Maybe all you need to do is reboot the router. Maybe it has a stale DNS cache.

11 replies
Question marked as Best reply

Feb 6, 2023 6:46 PM in response to hearthmatt

The problem is almost certainly inside your router. You said it works when you connect to ethernet. You also said you are using a Raspberry Pi. And you are using ssh. Those are all things that people do when they hack around with things. Maybe all you need to do is reboot the router. Maybe it has a stale DNS cache.

Feb 5, 2023 12:58 PM in response to hearthmatt

The -v output seems to indicate it is the destination Mac the rejected the connection.


A few things.


Boot both Macs into Safe Mode (just an experiment to see if 3rd party software is causing this; 3rd party software is not loaded in Safe mode)

Boot macOS Safe Mode: Start up your Mac in safe mode - Apple Support


Do you have multiple routers and/or WiFi access points? It is possible the the WiFi access point you are connecting to, is on a different sub-net from the Ethernet connection.


Feb 6, 2023 6:10 PM in response to BobHarris

Yes it is a valid IP address, these are the details from the Mac:


And I can ping it from the MacBook:


Last login: Sun Feb  5 18:57:01 on ttys000

matthew@OnesMacBookPro2 ~ % ping 192.168.2.66

PING 192.168.2.66 (192.168.2.66): 56 data bytes

64 bytes from 192.168.2.66: icmp_seq=0 ttl=64 time=10.716 ms

64 bytes from 192.168.2.66: icmp_seq=1 ttl=64 time=7.297 ms

64 bytes from 192.168.2.66: icmp_seq=2 ttl=64 time=5.513 ms

64 bytes from 192.168.2.66: icmp_seq=3 ttl=64 time=5.986 ms

^C

--- 192.168.2.66 ping statistics ---

4 packets transmitted, 4 packets received, 0.0% packet loss

round-trip min/avg/max/stddev = 5.513/7.378/10.716/2.035 ms

matthew@OnesMacBookPro2 ~ % ssh  192.168.2.66                                       

ssh: connect to host 192.168.2.66 port 22: Operation timed out

matthew@OnesMacBookPro2 ~ % 



Feb 4, 2023 3:14 PM in response to hearthmatt

Does ssh succeed in making the connection, and then disconnect after an idle period?


Or does the initial connection fail?


Are you using a password to connect, or are you using ssh-keygen keys?


If initial connection, does the destination Mac have System Preferences-> Sharing-> Remote Login enabled, and does it allow Everyone or at least your account access?


Are you using a VPN? Some VPNs block local access.


Are you running a 3rd party anti-virus package, or LittleSnitch. Some times these packages block ssh connections.


If it is the initial connection, try


ssh -v -v -v username@host.address


The verbose messages near the end should give a clue.


If you connect, but loose the connection after an idle period, then maybe add the following to your $HOME/.ssh/config file:


Host *
    ServerAliveInterval 240
    ServerAliveCountMax 2


240 is 5 minutes. Adjust according to your needs, but I would not lower it below 60 seconds.

Feb 5, 2023 11:59 AM in response to BobHarris

It's the initial connection that fails.


Both Macs have Remote Login enabled, and the account has access permission - it's the same account on both Macs.


I'm running Avast ant-virus but ssh requests from other computers go through without any issues.


Using the debug options I get:


matthew@OnesMacBookPro2 ~ % ssh -v -v -v  Matthew@192.168.2.66

OpenSSH_9.0p1, 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 *

debug2: resolve_canonicalize: hostname 192.168.2.66 is address

debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/matthew/.ssh/known_hosts'

debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/matthew/.ssh/known_hosts2'

debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling

debug3: ssh_connect_direct: entering

debug1: Connecting to 192.168.2.66 [192.168.2.66] port 22.

debug3: set_sock_tos: set socket 3 IP_TOS 0x48

debug1: connect to address 192.168.2.66 port 22: Operation timed out

ssh: connect to host 192.168.2.66 port 22: Operation timed out

matthew@OnesMacBookPro2 ~ % 


The target Mac is connected to my network via ethernet and the MacBook is generally connected via WiFi, but if I connect the MacBook to ethernet as well then ssh works in either direction. The IP addresses are different for ethernet and WiFi for both Macs, and also static.

Feb 6, 2023 2:32 PM in response to hearthmatt

Are you sure 192.168.2.66 is a valid IP address?


I am able to reproduce your Timeout error by attempting to ssh to an non-existent IP address:


$ ssh -v -v -v 172.16.1.222   # <<<---- INVALID IP address (no such device listening on this address)

OpenSSH_6.9p1, LibreSSL 2.1.8

debug1: Reading configuration data /Users/raharris/.ssh/config

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 21: Applying options for *

debug2: ssh_connect: needpriv 0

debug1: Connecting to 172.16.1.222 [172.16.1.222] port 22.

debug1: connect to address 172.16.1.222 port 22: Operation timed out

ssh: connect to host 172.16.1.222 port 22: Operation timed out


I also tried turning off Remote Login on the destination Mac, and I get a totally different error (Connection refused):


$ ssh -v -v -v bobm1max.local

OpenSSH_6.9p1, LibreSSL 2.1.8

debug1: Reading configuration data /Users/raharris/.ssh/config

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 21: Applying options for *

debug2: ssh_connect: needpriv 0

debug1: Connecting to bobm1max.local [172.16.1.xx] port 22.

debug1: connect to address 172.16.1.xx port 22: Connection refused

ssh: connect to host bobm1max.local port 22: Connection refused


You can find the Ethernet and WiFi IP addresses via


System Preferences -> Network -> Select Ethernet in left column -> Advanced -> TCP/IP (tab)


System Preferences -> Network -> Select WiFi in left column -> Advanced -> TCP/IP (tab)


You can also use the computer_name.local

System Preferences -> Sharing -> Computer Name: abcdefghi

Just under your computer name it should tell you the .local name. You can use that, just like I used bobm1max.local in one of my examples above.

ssh from MacBookPro to Mac times out

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