git Github (SSH) 通过公共 WIFI,端口 22 被阻止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7953806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 12:13:01  来源:igfitidea点击:

Github (SSH) via public WIFI, port 22 blocked

gitsshgithubwifipublic

提问by ostroon

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.

我目前在一个公共 WIFI 点上,我无法使用 SSH(他们可能阻止了那个端口)。但是,我需要该连接来执行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 pushto use that connection? How to do that? I'm on OSX (lion). This must be a common problem?

是否可以通过端口 80 设置 SSH 隧道并告诉github push使用该连接来绕过此限制?怎么做?我在 OSX(狮子)上。这应该是普遍问题吧?

回答by prtitrz

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

来源:https: //help.github.com/articles/using-ssh-over-the-https-port

回答by the_karel

The same works for Bitbucket:

同样适用于 Bitbucket:

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

via(outdated / dead)

通过(过时/已死)

via, updated(2015-10-29)

通过,更新(2015-10-29)

回答by Colin D Bennett

In addition to configuring it with the ~/.ssh/configfile, you can also simply include the port number in the remote URL you use. You just have to

除了使用~/.ssh/config文件对其进行配置之外,您还可以简单地在您使用的远程 URL 中包含端口号。你只需要

  1. use a proper URL like ssh://user@host:port/pathinstead of the user@host:pathshorthand; and

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

  1. 使用正确的 URLssh://user@host:port/path代替user@host:path简写;和

  2. ssh.子域添加到github.com.

For instance, instead of

例如,代替

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

use

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

回答by Jikku Jose

For gitlab, following can be added:

对于 gitlab,可以添加以下内容:

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

Source: Alternate Gitlab SSH Port

来源:备用 Gitlab SSH 端口

回答by Krishan K?nig

No need to modify the ~/.ssh/config. You can add another remote repository via git remote add ...

无需修改~/.ssh/config. 您可以通过添加另一个远程存储库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

回答by EsmaeelE

I find two ways

我找到两种方法

First

第一的

  • tor + torify
  • tor + torify

After successfully Install and configure tor on system simply run this to check ssh use tor.

在系统上成功安装和配置 tor 后,只需运行它来检查 ssh 使用 tor。

torify ssh -Tv [email protected]

torify ssh -Tv [email protected]



Second

第二

  • tor + privoxy + corkscrew
  • Tor + privoxy + 开瓶器

First configure tor from fist step. Then install privoxyto convert tor SOCKS5 to HTTP proxy.

首先从第一步配置 tor。然后安装privoxy将 SOCKS5 转换为 HTTP 代理。

sudo apt install privoxy

sudo apt install privoxy

Then install corkscrew

然后安装开瓶器

sudo apt install corkscrew

sudo apt install corkscrew

Place this config file in: ~/.ssh/config

将此配置文件放在:~/.ssh/config

host *
    ProxyCommand corkscrew 127.0.0.1 8118 %h %p

Or with ncat

或者用ncat

Host gitlab.com
        User git
        ProxyCommand ncat --proxy 127.0.0.1:8118 %h %p

Also can use ncinstead of ncat

也可以使用nc而不是ncat

    ProxyCommand nc --proxy 127.0.0.1:8118 %h %p

Now ssh can use configured proxy.

现在 ssh 可以使用配置的代理。