High Sierra SSH – Fix SSH Timeout Issues

high sierrassh

SSH stopped working suddenly. I am using macOS 10.13.4. I am getting timeout every time today but all was working yesterday. I have added my public key to GitHub. I get the following output upon running ssh:

$ssh -vvv -T git@github.com 
OpenSSH_7.7p1, OpenSSL 1.0.2o  27 Mar 2018
debug1: Reading configuration data /Users/nurrony/.ssh/config
debug1: /Users/nurrony/.ssh/config line 30: Applying options for github.com
debug1: /Users/nurrony/.ssh/config line 47: Applying options for *
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug2: resolving "github.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to github.com [192.30.255.113] port 22.
debug1: connect to address 192.30.255.113 port 22: Operation timed out
debug1: Connecting to github.com [192.30.255.112] port 22.
debug1: connect to address 192.30.255.112 port 22: Operation timed out
ssh: connect to host github.com port 22: Operation timed out

My ~/.ssh/config reads as follows:

Host github.com
  ControlMaster auto
  ControlPersist 120
  HostName github.com
  User git
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/nur-macbookpro
Host *
  # Always use SSH2.
  Protocol 2

  # Use a shared channel for all sessions to the same host,
  # instead of always opening a new one. This leads to much
  # quicker connection times.
  ControlMaster auto
  Controlpath /tmp/ssh-%r@%h:%p
  ControlPersist 1800

  # also this stuff
  Compression yes
  TCPKeepAlive yes
  ServerAliveInterval 20
  ServerAliveCountMax 10

I have tried every suggestion found by Web search but nothing is working. I can ssh fine when I connect my Mac with mobile hotspot.

How do I resolve this issue?

Best Answer

Have you tried the following:

  1. Are your identities active? (running: ssh-add -l will tell you).
  2. Since you're keeping your connections alive in the background for Github (not sure why you'd want to do that) once you go idle, the connection may lock you out.
  3. Have you checked your firewall settings to make sure port 22 access is enabled on your end?