Git hangs for a while, then gives up: ```text ssh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote repository. ``` Your key is not the problem. The connection never got far enough to offer one. Something between you and GitHub is dropping traffic on port 22, which is normal on corporate networks, many hotel and airport networks, and some mobile hotspots. GitHub publishes an SSH endpoint on port 443 for exactly this. Everything below was tested with OpenSSH 10.3 and Git 2.55.0. ## Read the Error Before Fixing It The wording tells you which problem you have, and they need different fixes. ### Connection timed out ```text ssh: connect to host github.com port 22: Connection timed out ``` Packets are being silently dropped, usually by a firewall. This is the case this guide fixes. ### Connection refused ```text ssh: connect to host github.com port 22: Connection refused ``` Something actively rejected the connection rather than ignoring it. Often a local proxy or VPN client. The port 443 route below usually still works. ### Permission denied (publickey) ```text git@github.com: Permission denied (publickey). ``` The network is fine and you reached GitHub. This is an authentication problem, so go to [Fix Permission Denied (publickey)][publickey] instead. ## Confirm the Port Is Blocked Test the two ports directly: ```bash ssh -T -o ConnectTimeout=10 git@github.com ssh -T -o ConnectTimeout=10 -p 443 git@ssh.github.com ``` If the first times out and the second answers, you have your diagnosis: ```text Hi you! You've successfully authenticated, but GitHub does not provide shell access. ``` That sentence is success. It is what a working GitHub SSH connection looks like, on either port. ## The Hostname Matters, Not Just the Port The SSH endpoint is a different host, `ssh.github.com`. Pointing SSH at `github.com` on 443 reaches the web server instead, which speaks HTTPS and hangs up: ```bash ssh -T -p 443 git@github.com ``` ```text Connection closed by 140.82.116.3 port 443 ``` Use `ssh.github.com` for port 443. This trips up people who change only the port. ## Make It Permanent Add this to `~/.ssh/config`, creating the file if it does not exist: ```text Host github.com HostName ssh.github.com Port 443 User git ``` That keeps every `git@github.com:owner/repo.git` remote you already have working, with no URL changes, because SSH rewrites the destination before connecting. Set the permissions SSH expects, or it ignores the file: ```bash chmod 600 ~/.ssh/config ``` Then verify Git itself, not just SSH: ```bash git ls-remote git@github.com:torvalds/linux.git HEAD ``` ```text 93f51579e7df248780214094418f205253383cc5 HEAD ``` A hash means Git is going over port 443 and working. Yours will differ, since that repository moves. ## If 443 Is Also Blocked Some networks allow only proxied HTTPS. Switch that repository to an HTTPS remote and authenticate with a token: ```bash git remote set-url origin https://github.com/you/your-repo.git ``` Then follow [Fix: Support for Password Authentication Was Removed][password-auth], since your account password will not work. ## What Not to Do * **Do not regenerate your SSH key.** A timeout happens before any key is offered, so a new key changes nothing. * **Do not disable host key checking.** `StrictHostKeyChecking=no` does not open a blocked port, and it removes a real protection. * **Do not add `Port 443` to `github.com` without changing `HostName`.** That reaches the web server, as shown above. * **Do not assume it is GitHub.** Check [GitHub status][github-status] first if every route fails, but a timeout on 22 with 443 working is your network. ## Verify ```bash ssh -T git@github.com git ls-remote git@github.com:you/your-repo.git HEAD ``` The first prints the "successfully authenticated" line, the second prints a hash. Both go over 443 now, and neither needed a change to any remote URL. ## Related Content * [Fix Permission Denied (publickey)][publickey] covers the error you get once the network is working and the key is not. * [Fix: Support for Password Authentication Was Removed][password-auth] is the fallback when SSH is blocked on every port. * [Fix: Host Key Verification Failed][host-key] covers the other error that stops an SSH connection before authentication. ## References * [Using SSH over the HTTPS port][github-ssh-443], GitHub's documentation for this endpoint. * [Troubleshooting SSH][github-ssh-troubleshooting], for the other SSH failure modes. * [ssh_config(5)][ssh-config], for `HostName`, `Port`, and how `Host` matching works. * [GitHub status][github-status], to rule out an outage. [publickey]: https://jeffbailey.us/blog/2019/11/10/setting-ssh-key-permissions/ [password-auth]: https://jeffbailey.us/blog/2026/09/21/git-password-authentication-removed/ [host-key]: https://jeffbailey.us/blog/2026/09/20/ssh-host-key-verification-failed/ [github-ssh-443]: https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port [github-ssh-troubleshooting]: https://docs.github.com/en/authentication/troubleshooting-ssh [ssh-config]: https://man.openbsd.org/ssh_config [github-status]: https://www.githubstatus.com/