22端口限制 git,通过公共WIFI的GitLab(SSH),端口22被阻止

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.

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.

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

解决方案

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.

How to switch origin to https so that pushing to gitlab.com works while on on Starbucks wifi

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

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

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

git commit README.md

git push

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值