Github (SSH) via public WIFI, port 22 blocked
GitSshGithubWifiPublicGit Problem Overview
I'm currently on a public WIFI spot and I'm unable to use SSH (they probably blocked that port). However, I need that connection to do a git push
.
➜ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection refused
Is it possible to bypass this restriction by setting up a SSH tunnel via port 80 and tell github push
to use that connection? How to do that? I'm on OSX (lion). This must be a common problem?
Git Solutions
Solution 1 - Git
Try this:
$ vim ~/.ssh/config
Add
Host github.com
Hostname ssh.github.com
Port 443
Source: https://help.github.com/articles/using-ssh-over-the-https-port
Solution 2 - Git
The same works for Bitbucket:
Host bitbucket.org
Hostname altssh.bitbucket.org
Port 443
via (outdated / dead)
via, updated (2015-10-29)
Solution 3 - Git
In addition to configuring it with the ~/.ssh/config
file, you can also simply include the port number in the remote URL you use. You just have to
-
use a proper URL like
ssh://user@host:port/path
instead of theuser@host:path
shorthand; and -
prepend the
ssh.
subdomain togithub.com
.
For instance, instead of
git@github.com:cdbennett/python-gitlab.git
use
ssh://[email protected]:443/cdbennett/python-gitlab.git
Solution 4 - Git
For gitlab, following can be added:
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
Source: Alternate Gitlab SSH Port
Solution 5 - Git
No need to modify the ~/.ssh/config
. You can add another remote repository via git remote add ..
.
// github
git remote add ssh://[email protected]:443/repo/name.git
// gitlab
git remote add ssh://[email protected]:443/repo/name.git
Solution 6 - Git
VPN (ExpressVPN) worked for me on JetBlue
Solution 7 - Git
I find two ways
First
- tor + torify
After successfully Install and configure tor on system simply run this to check ssh use tor.
torify ssh -Tv [email protected]
Second
- tor + privoxy + corkscrew
First configure tor from fist step. Then install privoxy to convert tor SOCKS5 to HTTP proxy.
sudo apt install privoxy
Then install corkscrew
sudo apt install corkscrew
Place this config file in: ~/.ssh/config
host *
ProxyCommand corkscrew 127.0.0.1 8118 %h %p
Or with ncat
Host gitlab.com
User git
ProxyCommand ncat --proxy 127.0.0.1:8118 %h %p
Also can use nc instead of ncat
ProxyCommand nc --proxy 127.0.0.1:8118 %h %p
Now ssh can use configured proxy.
[Edit]
Simpler version
Use torify before ssh command.
torify ssh -Tv [email protected]
To works with Privoxy+Tor may need to change default configs.
For me uncomment this line in /etc/privoxy/config
forward-socks5t / 127.0.0.1:9050 .
ssh config
Host *
ProxyCommand nc --proxy 127.0.0.1:8118 %h %p