Sunday, 23 February 2020

Using SSH over the HTTPS port

I met a problem when I try to connect github through ssh at home, but it does work at class( codeclan). 
git clone git@github.com:codeclan/e38_classnotes.git
Cloning into 'e38_classnotes'...
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights


I guess there has something wrong with the ssh and port 22. 

got some clue from askubuntu.com 
yes , I got some clue form askubuntu.comIf 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)

So, it could be the problem from firewall. 
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.
GitHub Enterprise users: Accessing GitHub Enterprise via SSH over the HTTPS port is currently not supported.
To test if SSH over the HTTPS port is possible, run this SSH command:
$ ssh -T -p 443 git@ssh.github.com
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.
If that worked, great! If not, you may need to follow our troubleshooting guide.

Enabling SSH connections over HTTPS

If you are able to SSH into git@ssh.github.com over port 443, you can override your SSH settings to force any connection to GitHub to run though that server and port.
To set this in your ssh config, edit the file at ~/.ssh/config, and add this section:
Host github.com
  Hostname ssh.github.com
  Port 443
You can test that this works by connecting once more to GitHub:
$ ssh -T git@github.com
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.

No comments:

Post a Comment