So I followed the guide on how to add a SSH key to GitHub, and added a new SSH key with a passphrase to GitHub and the SSH agent. Now, if I run ssh -T git@github.com as described in the guide to test if I set everything up correctly, it doesn't even prompt me for my passphrase, but immediately returns ssh: connect to host github.com port 22: Connection refused. I have both openssh-server and openssh-client installed and the SSH service is running.

the error

Help would be appreciated.

UPDATE: When I try and clone a repository which for which I have write access from a friend's GitLab instance, it throws the same error. Seems like this is a problem with SSH, not with the keys. (I have them added to the instance.)

  • You can't use ssh -T git@github.com. GitHub does not provide shell access. – A.B. Apr 18 '15 at 18:28
  • 1
  • Yes, that's right: % ssh -T git@github.com Hi <you_username>! You've successfully authenticated, but GitHub does not provide shell access. – A.B. Apr 18 '15 at 18:30
  • For this reason, you should rephrase your question. – A.B. Apr 18 '15 at 18:30
  • Check output of ssh -Tv git@github.com – Shagun Sodhani Apr 23 '15 at 10:11
up vote 4 down vote accepted

If you get a connection refused, it means you actually got a packet back which states that your destination does not accept your connection. This could mean a few things:

  1. github.com is down (not too likely, but you could always check their status on https://status.github.com/)

  2. you have an invalid IP address for github.com (manual entry in /etc/hosts or your resolver) which blocks ssh from at least your IP address

  3. you have a firewall along the way to github.com which blocks the ssh traffic (eg. local firewall or corporate firewall)

Have you tried using port 443, and adding ssh. subdomain prefix?

This command will test it. You should get an error since a shell is not supported.

ssh -T -p 443 git@ssh.github.com

Then you can use a full URL to specify the project path, see Stack Overflow answer for details:

ssh://git@ssh.github.com:443/yourname/reponame.git
  • This helps to confirm that at least the connection to github can be made. $ ssh -T -p 443 git@ssh.github.com The authenticity of host '[ssh.github.com]:443 ([192.30.253.123]:443)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[ssh.github.com]:443,[192.30.253.123]:443' (RSA) to the list of known hosts. Hi xcaliber! You've successfully authenticated, but GitHub does not provide shell access. – Bhoom Suktitipat May 30 at 3:12
  • Thank you! This worked for me and made me realize that I also had to add this to my ssh config file # GitHub Account Host github.com HostName **ssh.github.com** Port **443** PreferredAuthentications publickey IdentityFile <path to your private ssh key> *note the HostName and Port – Brandon Manchester Nov 5 at 17:09

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.