Unable to connect to remote server using SSH

Hello,


I am developing an IOS application that requires the use of a server. I use my MacBook Pro to connect to this server and since a month now I am facing technical difficulties. The problem occurs when I try to use the ssh protocol to connect to my remote server using the 'ssh' command in the terminal. The command stalls for a while and then returns with "port 22: Operation timed out". This problem seems to only be occurring when connected to a WiFi network.

Although there could be multiple causes to this problem, I suspect it to be a bug or routing setting in the mac OS software. I did several tests to determine what causes this problem. The tests include using different networks and different devices.

-- Tests --

Wifi network 1 (Work):

MacBook pro: Operation timed out.

IPhone 7 (Termius app): Operation timed out.

Lenovo (windows): Instant successful connection

Wifi network 2 (Home):

MacBook pro: Operation timed out.

IPhone 7 (Termius app): Operation timed out.

Lenovo (windows): Instant successful connection

Wifi network 3 (public):

MacBook pro: Operation timed out.

IPhone 7 (Termius app): Operation timed out.

4G celluar network:

IPhone 7 (Termius app): Instant successful connection

---------

I cannot explain this behaviour and I tend to conclude that the connection does not work when using any mac system on a wifi network.

Other points that are worth mentioning.

- Before like a month ago, I never had issues with this at all. Everything worked fine. I also can't think of any significant change that might have caused this.

- I can perform http requests successfully at the same ip address.

- I tried using keys instead of passwords but yielded no results.

- Every once in a while, the connection is successful. I estimate this i about 5% of the time.

- When rebooting the mac, the connection seems to work more often for a short period of time. Approximately 5 min.

- I face similar connection issues, when my VoIP app tries to establish a peer-to-peer connection outside of the local network. This could be coincidence and not related at all.

What could be the cause of this? Any idea's or suggestions. Hope you can point me in the right direction.

Kind regards,

Daan.

Replies

First up, you should test whether this is an SSH-specific problem or a network connectivity problem in general. You can do that by attempting to connect using

nc
. If the connection succeeds, you should see the initial greeting from the SSH server:
$ nc fluffy.local. 22
SSH-2.0-OpenSSH_6.9
^C

If this doesn’t work then you have connectivity problems, and the next step is to use a packet trace to see what’s happening on the ‘wire’. You can start by running that packet trace on your Mac, but you may end up needing to run it on the network itself to confirm whether packets are actually making it off your Mac. See Recording a Packet Trace.

OTOH, if

nc
works but
ssh
doesn’t, that suggests an SSH-specific problem, and the next step would be to enable debug logging on the SSH client (via the
-v
option). See the
ssh
man page for details.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for the quick reply,


I used the nc command, but received no greeting from the server.

I then started recording the packet traces and found TCP Retransmission errors.

see the screenshot here. https://imgur.com/a/Kuno1O6


Any idea what could cause this problem and how to fix it?


Also, the last couple days I had no issue connecting at all. Pretty strange since I did not make any changes to the system.


Thank you for your help and kind regards,


Daan.

I then started recording the packet traces and found TCP Retransmission errors.

Any idea what could cause this problem and how to fix it?

To figure out what’s going on here you need to add more packet traces. I recommend that you start by running a packet trace on the server itself. That’ll tell you whether:

  • The SYN packets are making it to the server

  • The server is responding with a SYN-ACK, but that’s not getting back to the clients

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"