Github (SSH) via public WIFI, port 22 blocked
Asked Answered
H

7

209

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 [email protected]
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?

Hollyhock answered 31/10, 2011 at 12:37 Comment(1)
Anyone know how to do this for Launchpad.net?Scrapbook
P
441

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

Peninsula answered 10/11, 2011 at 14:45 Comment(9)
@Peninsula any idea what's the config for heroku?Metallo
just fyi, you don't have to open the file with vim.Macaronic
This is great! But I too need to do this for heroku. Any ideas?Faircloth
Refer to serverfault.com/a/253314 if you are getting Bad owner or permissions on /home/.../.ssh/configNinepins
Anyone know how to do this for launchpad.net?Scrapbook
Thanks! Your answer solved my problem 10 years later !Hydrogenate
probably more general-user-friendly to switch vim for nano here. ¯\_(ツ)_/¯Bald
Didn't work for me, still not being able to pushOat
ssh: connect to host ssh.github.com port 443: Resource temporarily unavailableAmabelle
H
49

The same works for Bitbucket:

Host bitbucket.org
  Hostname  altssh.bitbucket.org
  Port  443

via (outdated / dead)

via, updated (2015-10-29)

Harvey answered 25/5, 2014 at 12:12 Comment(0)
L
32

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

  1. use a proper URL like ssh://user@host:port/path instead of the user@host:path shorthand; and

  2. prepend the ssh. subdomain to github.com.

For instance, instead of

[email protected]:cdbennett/python-gitlab.git

use

ssh://[email protected]:443/cdbennett/python-gitlab.git
Languid answered 23/12, 2015 at 22:44 Comment(2)
This worked for me: ssh://[email protected]/repo.git but without the 443 port, as that gave me an error.Baron
But I only did this on the directory of the project with git config --local -eBaron
V
11

For gitlab, following can be added:

Host gitlab.com
  Hostname altssh.gitlab.com
  User git
  Port 443

Source: Alternate Gitlab SSH Port

Varick answered 3/8, 2017 at 1:47 Comment(0)
H
3

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
Hallerson answered 20/2, 2020 at 1:36 Comment(0)
W
1

VPN (ExpressVPN) worked for me on JetBlue

Wert answered 1/9, 2021 at 16:45 Comment(0)
M
-2

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
Macdonell answered 9/4, 2020 at 18:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.