我使用星巴克 wifi,在尝试推送到 gitlab.com 存储库时收到以下信息:
$ 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 public WIFI, port 22 blocked将以下内容添加到 ~/.ssh/config
Host gitlab.com
Hostname gitlab.com
Port 443
但这不起作用,因为我收到此错误:
$ 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 吗?
最佳答案
自 2016 年 2 月起,您不再需要切换到 https。
您可以在端口 443(通常为 https 事务保留的端口)上通过 ssh 推送到 GitLab
参见“GitLab.com now supports an alternate git+ssh port”
GitLab.com 运行第二个 SSH 服务器,该服务器监听常用端口 443,该端口不太可能受到防火墙保护。
All you have to do is edit your
~/.ssh/config
and change the way you connect to GitLab.com.
The two notable changes are Hostname and Port:
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab
[您可能需要更改远程源网址:
git remote set-url origin altssh.gitlab.com:user/myrepo.git
]
The first time you push to
altssh.gitlab.com
you will be asked to verify the server’s key fingerprint:
The authenticity of host '[altssh.gitlab.com]:443 ([104.208.154.249]:443)' can't be established.
ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.
Are you sure you want to continue connecting (yes/no)?
That’s only normal since you are connecting to the new loadbalancer. If you watch closely, the key fingerprint is the same as in GitLab.com.
关于ssh - GitLab (SSH) 通过公共(public) WIFI,端口 22 被阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32669420/