GitLab (SSH) 通过公共 WIFI,端口 22 被封锁 [英] GitLab (SSH) via public WIFI, port 22 blocked

查看:119
本文介绍了GitLab (SSH) 通过公共 WIFI,端口 22 被封锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Starbucks wifi 并在尝试推送到 gitlab.com 存储库时得到以下信息:

I using Starbucks wifi and I get the following when trying to push to a gitlab.com repo:

  $ git push origin master
  ssh: connect to host gitlab.com port 22: Connection refused
  fatal: Could not read from remote repository.

我尝试为 GitHub 调整解决方法:Github (SSH) via公共 WIFI,端口 22 被阻止 通过将以下内容添加到 ~/.ssh/config

I tried adapting a workaround for GitHub: Github (SSH) via public WIFI, port 22 blocked by adding the following to ~/.ssh/config

 Host gitlab.com
        Hostname gitlab.com
        Port 443

但这不起作用,因为我收到此错误:

But that doesn't work as I get this error:

 $ git push origin master
 ssh_exchange_identification: Connection closed by remote host
 fatal: Could not read from remote repository.

 Please make sure you have the correct access rights
 and the repository exists.

我有一个解决方法可以让我使用端口 443 推送到 GitLab.com?

I there a workaround that will allow me to push to GitLab.com using port 443?

推荐答案

感谢@oleg-gopkolov 给我提示尝试以不同方式定义原点!事实证明 ssh 端口 443 不起作用,但 https 如下所示.

Thanks to @oleg-gopkolov for giving me the hint to try defining the origin differently! It turns out ssh port 443 didn't work but https did as per below.

这里是切换到 https 的命令(如果您尝试过其他更改并且您的本地已过时,就像我的那样,您还需要遵循 无法推送到 GitHub - 一直说需要合并):

Here are the commands to switch to https (if you had experimented with other changes and your local is out of date like mine was you will also need to follow Cannot push to GitHub - keeps saying need merge ):

git remote remove origin
git remote add origin https://gitlab.com/your_username/your_repo.git
git push --set-upstream origin master

如果您想在新结账时进行一些测试

事实证明,使用 https 结帐选项确实有效.因此,如果您不介意重新结帐,您可以在星巴克 wifi 上运行它:

If you want to do some testing on a fresh checkout

It turns out that using the https checkout option does work. So provided you don't mind a fresh checkout, you can run this on Starbucks wifi:

git clone https://gitlab.com/your_username/your_repo.git

然后要测试提交,您可以编辑 README.md 然后运行:

Then to test committing you can edit README.md and then run:

  git commit README.md
  git push

如果您想确认 SSH GitLab 访问在 Starbucks wifi 上不起作用

要确认 SSH 克隆在 Starbucks 中不起作用,您可以运行以下 3 个命令之一:

If you want to confirm that SSH GitLab access doesn't work on Starbucks wifi

To confirm that SSH cloning does not work at Starbucks you can run one of the following 3 commands:

git clone git@gitlab.com:your_username/your_repo.git
git clone git@gitlab.com:443/your_username/your_repo.git
git clone ssh://gitlab.com:443your_username/your_repo.git

对于每一个,您都会收到如下错误:

And for each one you will get an error like this:

Cloning into 'your_repo'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

这篇关于GitLab (SSH) 通过公共 WIFI,端口 22 被封锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆