主機金鑰驗證失敗 SSH Github

主機金鑰驗證失敗 SSH Github

我採用了一種相對簡單的方法來嘗試安全地複製我的 GitHub 儲存庫,但仍然很困難。

在我的 Mac 上,我運行指定名稱為 MyKey 且沒有密碼

ssh-keygen -t rsa

我將公鑰的內容上傳到具有讀寫權限的 GitHub。然後我在我的伺服器上運行以下命令:

cat > /root/.ssh/github.id_rsa << EOF
-----BEGIN OPENSSH PRIVATE KEY-----
The private key 
-----END OPENSSH PRIVATE KEY-----
EOF

chmod 600 /root/.ssh/github.id_rsa
    
cat > /root/.ssh/config << EOF
    Host github.com
    Hostname github.com
    IdentityFile ~/.ssh/github.id_rsa
EOF
chmod 600 /root/.ssh/config

git clone [email protected]:myname/myproject.git /var/www/test

然而我得到的錯誤是:

Cloning into '/var/www/test'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

我可能哪裡出錯了?

相關內容