我使用星巴克wifi,尝试推送到gitlab.com仓库时得到以下信息:
$ git push origin master
ssh: connect to host gitlab.com port 22: Connection refused
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
我尝试通过GitHub改编GitHub的解决方法:Github(SSH),通过将以下内容添加到〜/ .ssh / config来阻止端口22
Host gitlab.com
Hostname gitlab.com
Port 443
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为我收到此错误:
$ 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.
Run Code Online (Sandbox Code Playgroud)
我有一个解决方法,可以使用端口443推送到GitLab.com吗?
自2016年2月起,您不再需要切换到https。
您可以在...端口443(通常为https事务保留的端口)中的ssh中推送到GitLab。
请参阅“ GitLab.com现在支持备用git + ssh端口 ”
GitLab.com运行第二个SSH服务器,该服务器侦听不太可能被防火墙保护的常用端口443。
您要做的就是编辑您的
~/.ssh/config
并更改连接到GitLab.com的方式。
两项值得注意的更改是主机名和端口:
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab
Run Code Online (Sandbox Code Playgroud)
[您可能需要更改远程原始URL:
git remote set-url origin altssh.gitlab.com:user/myrepo.git
Run Code Online (Sandbox Code Playgroud)
]
首次按下时,
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)?
Run Code Online (Sandbox Code Playgroud)
这是正常现象,因为您要连接到新的负载均衡器。如果您仔细观察,其关键指纹与GitLab.com中的相同。
感谢@oleg-gopkolov 给我提示,让我尝试以不同的方式定义原点!事实证明 ssh 端口 443 不起作用,但 https 起作用,如下所示。
以下是切换到 https 的命令(如果您尝试过其他更改,并且您的本地版本像我的一样已经过时,您还需要遵循Cannot Push to GitHub - keep said need merge):
git remote remove origin
git remote add origin https://gitlab.com/your_username/your_repo.git
git push --set-upstream origin master
Run Code Online (Sandbox Code Playgroud)
事实证明,使用 https 结账选项确实有效。因此,如果您不介意重新结帐,您可以在星巴克 wifi 上运行此命令:
git clone https://gitlab.com/your_username/your_repo.git
Run Code Online (Sandbox Code Playgroud)
然后要测试提交,您可以编辑 README.md 然后运行:
git commit README.md
git push
Run Code Online (Sandbox Code Playgroud)
要确认 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
Run Code Online (Sandbox Code Playgroud)
对于每一个,您都会收到如下错误:
Cloning into 'your_repo'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6620 次 |
最近记录: |