6

I am experiencing a timeout connection error when using ssh from my MacBook to connect to an external server. The problem started immediately after having updated to macOS 10.15.6. I could connect smoothly before that. The server is working correctly, I can connect from other machines.

$ ssh -v T800                   
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/XYZ/.ssh/config
debug1: /Users/XYZ/.ssh/config line 22: Applying options for T800
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: connect to address xxx.xxx.xxx.xxx port 22: Operation timed out
ssh: connect to host xxx.xxx.xxx.xxx port 22: Operation timed out

/etc/ssh/ssh_config contains a bunch of commented lines and then:

Host *
        SendEnv LANG LC_*

While /Users/XYZ/.ssh/config for T800 is:

Host T800
        Hostname xxx.xxx.xxx.xxx
        User john
        Port 22
        UserKnownHostsFile ~/.ssh/know_hosts

The firewall of my MacBook is turned off, and the one on the server is correctly configured. I can ping the server from my MacBook and I can access it via ssh from other machines, including my second MacBook wich is still running an older version of macOS.

A similar (yet different) problem is described here, I tried the solution proposed but it didn't work in my case.

Any clue?

6
  • 1
    Have a look at the last two lines where is says “Operation timed out.”. This means that your SSH client tried to establish the connection, however it sat waiting for the server to respond. It gave up when it didn’t get a response. Typically a firewall will cause a rejection, but check your and the server for firewall(s) between you two. Also make sure that the server is up and running and accepting connections.
    – Allan
    Aug 26, 2020 at 22:07
  • The firewall on my Mac is turned off. The server is well configured, it was working before the update and it is working from other machines, I can ssh in the server from other computers. Pinging the server IP works as well.
    – alec_djinn
    Aug 27, 2020 at 6:51
  • 1
    Try increasing verbosity (-vvv). Also - try to compare any relevant ssh config files (user and system ones) from the working mac - are there any differences? (I guess that the system upgrade has overwritten something?)
    – Iľja
    Aug 27, 2020 at 8:56
  • 1
    I have tried the resetting NVRAM, but it only works the first time. After that it always indicates timeout Any other suggestion will be greatly appreciated. Oct 30, 2020 at 15:52
  • @ShaoqunZhou I don't know how to help. It worked for me and I don't have problems with it anymore.
    – alec_djinn
    Oct 31, 2020 at 12:56

3 Answers 3

3

My issue seems related to this one. Hope my solution will nudge others in the right direction.

I once updated my macOS to 10.15.4 and started having problems: git pull and git push would hang indefinitely for GitHub. Checked all the forums and tried all solutions, but nothing worked. I eventually started using a Linux laptop for git repositories. Returned to this problem today and got onto something.

Not only git pull and git push hang, but also ssh -T [email protected]. Decided to replace github.com with the actual IP address and it worked!

I ran:

$ ssh -T [email protected]
^c (hung indefinitely)
$ nslookup github.com
192.30.255.113
$ ssh -T [email protected]
Hi user! You've successfully authenticated, but GitHub does not provide shell access.

I didn't try to dig deeper yet, just used a workaround:

$ git remote add alt [email protected]:user/repo.git

Now to pull and push from GitHub, I run:

  • git pull alt master
  • git push alt master

Update

I don't have issues pinging github.com, so my DNS servers are set up correctly. The DNS resolution issue only shows up when I try to ssh to github.com.

1

Somehow resetting NVRAM solved the issue. I am still puzzled about the cause of the bug, but at least I got ssh working properly again.

Here is a link to an Apple help-document on how to do this: https://support.apple.com/en-us/HT204063

2
  • 3
    There is nothing in NVRAM that has anything to do with networking. You can see the contents with nvram -xp. More than likely is was the reboot that naturally happens when you do an NVRAM reset.
    – Allan
    Oct 19, 2020 at 19:50
  • I try reboot before applying above suggestion. Restart didn't help. Maybe full stop and start was a fix?
    – Wawrzek
    Oct 20, 2020 at 15:27
0

I finally made it works.

Open System Preferences > Security & Privacy > General, then login to ssh in the Terminal. It will give you a warning about 'ssh' with options of Put in trash or Cancel. Hit Cancel then in the System Preferences panel, you will see that ssh is blocked. Hit Open anyway, then it works.

Same thing with sftp.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .