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 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 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 GitHub does not provide shell access. – A.B. Apr 18 '15 at 18:28
  • 1
  • Yes, that's right: % ssh -T 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 – 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. is down (not too likely, but you could always check their status on

  2. you have an invalid IP address for (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 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

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

  • This helps to confirm that at least the connection to github can be made. $ ssh -T -p 443 The authenticity of host '[]:443 ([]: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 '[]:443,[]: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 HostName **** 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.