For me none of the suggested solutions worked so I tried to fix it myself and I resolved it. I was getting this error on my AWS EC2 UBUNTU instance. I edited the ssh config (or add it if it does not exist).
nano ~/.ssh/config
And I added the following
Host github.com
Hostname ssh.github.com
Port 443
Then, run the command ssh -T [email protected]
to confirm if the issue is fixed.
According to this
Sometimes, firewalls refuse to allow SSH connections entirely. If using HTTPS cloning with credential caching is not an option, you can attempt to clone using an SSH connection made over the HTTPS port. Most firewall rules should allow this, but proxy servers may interfere
Hopefully this helps anyone else who’s having the same issue I did.