我目前正在使用公共WIFI,无法使用SSH(他们可能封锁了该端口)。然而,我需要该连接来进行git push
。
➜ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection refused
通过在端口80上设置SSH隧道并告诉github push
使用该连接,是否可以绕过此限制?如何做到这一点?我使用的是OSX(lion)。 这一定是一个常见的问题吗?
我目前正在使用公共WIFI,无法使用SSH(他们可能封锁了该端口)。然而,我需要该连接来进行git push
。
➜ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection refused
通过在端口80上设置SSH隧道并告诉github push
使用该连接,是否可以绕过此限制?如何做到这一点?我使用的是OSX(lion)。 这一定是一个常见的问题吗?
试一下这个:
$ vim ~/.ssh/config
添加
Host github.com
Hostname ssh.github.com
Port 443
来源:https://help.github.com/articles/using-ssh-over-the-https-port
除了使用~/.ssh/config
文件配置外,您还可以在使用远程URL时直接包含端口号。只需要:
使用类似ssh://user@host:port/path
这样的正确格式的URL,而不是user@host:path
的简写形式;以及
在github.com
之前添加ssh.
子域名。
例如,您可以将以下命令:
git@github.com:cdbennett/python-gitlab.git
使用
ssh://git@ssh.github.com:443/cdbennett/python-gitlab.git
ssh://git@ssh.github.com/repo.git
,但是不要使用443端口
,因为那会导致错误。 - Precious OSSAIgit config --local -e
命令。 - Precious OSSAI~/.ssh/config
。你可以通过git remote add ..
添加另一个远程仓库。// github
git remote add ssh://git@ssh.github.com:443/repo/name.git
// gitlab
git remote add ssh://git@altssh.gitlab.com:443/repo/name.git
VPN(ExpressVPN)在JetBlue上对我有效
第二步
首先从头开始配置tor。 然后安装privoxy将tor SOCKS5转换为HTTP代理。
sudo apt install privoxy
接着安装corkscrew
sudo apt install corkscrew
将此配置文件放置在:~/.ssh/config
host *
ProxyCommand corkscrew 127.0.0.1 8118 %h %p
或使用 ncat
Host gitlab.com
User git
ProxyCommand ncat --proxy 127.0.0.1:8118 %h %p
也可以使用nc代替ncat
ProxyCommand nc --proxy 127.0.0.1:8118 %h %p
现在ssh可以使用配置的代理。
[编辑]
简化版本
在ssh命令前使用torify。
torify ssh -Tv git@gitlab.com
要使用Privoxy+Tor,可能需要更改默认配置。对于我来说,在/etc/privoxy/config
中取消注释此行。
forward-socks5t / 127.0.0.1:9050 .
ssh 配置
Host *
ProxyCommand nc --proxy 127.0.0.1:8118 %h %p