簡體   English   中英

git 克隆失敗,ssh 端口 22 連接超時

[英]git clone fails with ssh port 22 connection timed out

我從Windows 11工作站通過Oracle VM VirtualBox安裝了CentOS 7 nix OS。 然后我通過Docker 安裝了最新的 gitlab 到目前為止,我能夠做到以下幾點:

  • gitlab運行成功
  • 我能夠從瀏覽器訪問其 web 控制台
  • 我能夠以John的身份創建新用戶(非 root)
  • 我能夠創建一個新項目作為hello-world並為該用戶創建 ssh 密鑰對
  • 我在Windows 11上運行 git bash 並運行ssh-keygen來創建密鑰對

The problem I am having is when I tried to run git clone git@localhost:john/hello-world.git I am getting ssh: connect to host localhost.com port 22: Connection timed out fatal: Could not read from remote repository. .

我閱讀了一些關於它的文章,包括這個並嘗試了它的建議解決方案,雖然我不明白: ssh: connect to host github.com port 22:

如果有人能向我解釋為什么會發生這種情況/如何解決它,我將不勝感激。 我是 linux + 網絡 + ssh 的新手。

更新

這不是我發布的問題的解決方案,而是我的臨時解決方案。

我決定使用用戶名/密碼,而不是使用ssh 密鑰,這允許我下載git bash中的存儲庫。 我做了兩件事。

  1. 我在C:\Windows\system32\drivers\etc\hosts上添加了 VM 的 IP 地址及其主機名 - 這是我應該先完成的,新手的錯誤。
  2. 之后,我運行git clone http://john@localhost/john/hello-world.git

首先確保您完全可以通過 ssh 訪問您的 VM:運行

ssh <user>@<host>

# you can add '-v' to have more information on what ssh is trying to do

兩個備注:

  • 主機:如果您的虛擬機可以通過您的主機網絡訪問,則它不會使用 127.0.0.1 IP ( localhost )。 嘗試連接到虛擬機的 IP,或者,如果您在etc/hosts中為您的虛擬機添加了一個名稱,則使用此名稱: ssh git@mylocalvm

  • 用戶帳戶:您提到您創建了一個john帳戶,但沒有創建git帳戶。 在您的 VM 上創建一個非 root git帳戶,或嘗試ssh john@mylocalvm

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM