use*_*672 6 git connection ssh gitlab
在过去的几天里,我一直无法推送到远程(gitlab),它在此之前一直有效。我知道这个问题有 10 个类似的问题,也许答案就在其中的某个地方。然而,我一直在尝试许多建议的解决方案 - 但徒劳。
当我推动时,我得到:
ssh: connect to host gitlab.com port 22: Connection refused
fatal: The remote end hung up unexpectedly
本地位于宪法服务器上,这里的许多人都使用端口 22 主要用于 github,没有任何问题。这是否可能是我这边的防火墙设置可能与 gitlab 特别相关?管理员确保这不是简单的白名单问题。
我的 gitlab 网址如下:
origin git@gitlab.com:myname/myproject.git (fetch)
origin git@gitlab.com:myname/myproject.git (push)
我尝试使用替代的 ssh 格式更新 git-url:
origin ssh://git@gitlab.com/myname/myproject.git (fetch)
origin ssh://git@gitlab.com/myname/myproject.git (push)
我已经尝试了端口 22 和替代端口 443 - 这是文件~/.ssh/config
:
Host gitlab.com
RSAAuthentication yes
IdentityFile ~/.ssh/id_rsa
选择:
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
我尝试过使用 https 连接(徒劳)。
制作了新的 ssh 密钥(徒劳)。
我迷失了要尝试的事情,并且我的分支比原点领先了很多提交。我在这里错过了一些简单的尝试吗?
更新
当删除 ~/.ssh/config 并发出ssh -Tv git@gitlab.com
它仍然不起作用时 - 我得到:
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to gitlab.com [52.167.219.168] port 22.
debug1: connect to address 52.167.219.168 port 22: Connection refused
ssh: connect to host gitlab.com port 22: Connection refused
Run Code Online (Sandbox Code Playgroud)
更新 2 事实 证明,我们的机构服务器没有将 gitlab.com 列入白名单,因为与 github.com 相比,它们不提供官方 IP 地址范围。我的解决方案是从我的工作站计算机到包含我的项目的服务器创建一个挂载点,然后通过计算机推送/拉取 git 目录。
确保您的案例中没有 ~/.ssh/config
文件:您提到的默认 URL 应该在没有config
文件的情况下工作。
并确保内容~/.ssh/id_rsa.pub
已注册到您的帐户。
测试情况是否如此:
ssh -Tv git@gitlab.com
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,则意味着 ssh 端口被阻止,或者 ISP 不允许访问远程站点。
事实证明OP提到了第二种情况:
我们的机构服务器不会将 gitlab.com 列入白名单,因为与 github.com 相比,它们不提供官方 IP 地址范围。
我的解决方案是从我的工作站计算机到包含我的项目的服务器创建一个挂载点,然后通过计算机推送/拉取 git 目录。