GitHub SSH push fails on some networks? Try using port 443 instead of 22

Sometimes I find that I can’t push to GitHub using SSH on certain networks.

The error usually isn’t obvious at first, but after checking more closely, the real reason is that port 22 is blocked (common on office, campus, or public networks).

GitHub provides an alternative SSH endpoint that works over port 443, which is usually allowed.

You can fix this quickly by running:

export GIT_SSH_COMMAND="ssh -oHostName=ssh.github.com -oPort=443"

After setting this, Git commands like git push and git pull should work normally over SSH, even when port 22 is blocked.

This is especially useful if:

  • You’re on a company or school network
  • You don’t want to switch your remote to HTTPS
  • SSH works at home but fails elsewhere

Just sharing this in case it helps someone who runs into the same issue :+1: