A Git SSH remote (git@github.com:...) connects to host github.com on port 22
by default. Some networks, often captive-portal or hotel Wi-Fi, block outbound
port 22, so the connection never completes and Git fails with a timeout. GitHub
also serves SSH on ssh.github.com port 443, the HTTPS port, which is almost
never blocked. Pointing github.com at that endpoint in the SSH config fixes it
without changing any remote URLs.
The symptom
Push, pull, or ssh -T hangs for a while, then times out. Keys and the repo are
fine, the packets just never leave the network.
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.Confirm port 22 is blocked
Test the two ports without extra tools using the bash /dev/tcp builtin. If 22
hangs and 443 connects, the network is blocking 22, not GitHub or your keys.
timeout 5 bash -c '</dev/tcp/github.com/22' && echo "22 open" || echo "22 blocked"
timeout 5 bash -c '</dev/tcp/ssh.github.com/443' && echo "443 open" || echo "443 blocked"Route github.com over 443
Add a host block to ~/.ssh/config (create the file if it does not exist). This
rewrites the connection: commands still target github.com, but SSH dials
ssh.github.com on 443 instead.
Host github.com
HostName ssh.github.com
User git
Port 443Only the destination host and port change, from github.com:22 to
ssh.github.com:443. The protocol, keys, and authentication are identical, so no
remote URLs need editing. The Host github.com alias catches every remote that
uses git@github.com.
Verify
Authenticate, then use Git normally.
ssh -T git@github.com # greets you by username
git pushA successful greeting confirms Git is now reaching GitHub over 443.