[英]Problem with Git: "ssh: connect to host gitlab port 22: connection refused"
[英]gitlab connection refused ssh port 22 and 443
在過去的幾天里,我一直無法推送到遠程 (gitlab),它在此之前就已經工作了。 我知道這個問題有 10 個類似的 SO 問題,也許答案就在其中。 但是,我一直在嘗試許多建議的解決方案 - 但徒勞無功。
當我推動時,我得到:
ssh: connect to host gitlab.com port 22: Connection refused fatal: The remote end hung up unexpectedly
本地在憲法服務器上,這里的許多人都在使用端口 22,主要用於 github,沒有問題。 這可能是我這邊的防火牆設置,可能與 gitlab 具體相關嗎? 管理員確保這不是簡單的白名單問題。
我的 gitlab url 是:
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
更新 2結果表明,我們的機構服務器沒有將 gitlab.com 列入白名單,因為與 github.com 相比,它們不提供官方 IP 地址范圍。 我的解決方案是從我的工作站計算機到包含我的項目的服務器創建一個掛載點,然后通過計算機推送/拉取 git 目錄。
確保您的案例中沒有~/.ssh/config
文件:您提到的默認 URL 應該在沒有config
文件的情況下工作。
並確保~/.ssh/id_rsa.pub
已注冊到您的帳戶。
測試是否是這種情況:
ssh -Tv git@gitlab.com
如果這不起作用,則意味着 ssh 端口被阻止,或者 ISP 不授予對遠程站點的訪問權限。
原來 OP 提到了第二種情況:
我們的機構服務器不會將 gitlab.com 列入白名單,因為與 github.com 相比,它們不提供官方 IP 地址范圍。
我的解決方案是從我的工作站計算機到包含我的項目的服務器創建一個掛載點,然后通過計算機推/拉 git 目錄。
如果你得到錯誤..
ssh: connect to host git.my-host.com port 22: Connection refused
fatal: Could not read from remote repository.
..那么您可以通過刪除 GitLab 主機的 IP 條目來解決它
~/.ssh/known_hosts
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.