我使用星巴克wifi,在尝试推送到gitlab.com回购时我得到以下信息:
$ git push origin master
ssh: connect to host gitlab.com port 22: Connection refused
fatal: Could not read from remote repository.
我尝试通过在〜/ .ssh / config
中添加以下内容来为GitHub调整解决方法:Github (SSH) via public WIFI, port 22 blocked 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吗?
答案 0 :(得分:4)
自2016年2月起,您不再需要切换到https 您可以在...端口443(通常为https事务保留的端口)上的ssh中推送到GitLab
请参阅" GitLab.com now supports an alternate git+ssh port"
GitLab.com运行第二个SSH服务器,该服务器侦听常用的端口443,该端口不太可能被防火墙。
您只需编辑
~/.ssh/config
并更改连接GitLab.com的方式。
两个值得注意的变化是主机名和端口:
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab
[您可能需要更改远程源URL:
git remote set-url origin altssh.gitlab.com:user/myrepo.git
第一次按
altssh.gitlab.com
时,系统会要求您验证服务器的密钥指纹:
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)?
这是正常的,因为您连接到新的负载均衡器。如果你仔细观察key fingerprint is the same as in GitLab.com。
答案 1 :(得分:2)
感谢@ oleg-gopkolov给我提示尝试以不同方式定义原点!事实证明,ssh端口443无法正常工作,但https确实如下所示。
以下是切换到https的命令(如果您已经尝试过其他更改,而且您的本地已经过时,就像我一样,您还需要关注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 checkout选项确实有效。所以,如果您不介意结账,可以在星巴克wifi上运行:
git clone https://gitlab.com/your_username/your_repo.git
然后,为了测试提交,您可以编辑README.md,然后运行:
git commit README.md
git push
要确认SSH克隆在星巴克不起作用,您可以运行以下3个命令之一:
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
对于每一个你都会得到这样的错误:
Cloning into 'your_repo'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
答案 2 :(得分:1)
定义您的遥控器,使其使用端口443
git remote add origin ssh://some.host:443/path/to/repo.git