【发布时间】:2021-09-24 14:33:27
【问题描述】:
我在两个主机中有两个存储库。我最近在 GitHub 中配置了 ssh github 正在工作,但不是“其他”。所以我将密钥添加到 ~/.ssh/config 如下。
Host other
HostName other.host
IdentityFile ~/.ssh/id_rsa
User git
Host github
HostName github.com
IdentityFile ~/.ssh/id_ed25519
User git
但是现在,对“其他”的 git 操作有效,但对 GitHub 无效。
我试过了
我删除了know_hosts 文件并重试。似乎 ssh 正在为“github.com”使用id_rsa 密钥
$ git pull
The authenticity of host 'github.com (140.82.121.4)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?yes
Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
s1n7ax@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我尝试重启 sshd
sudo systemctl restart sshd.service
【问题讨论】:
-
Host github与github.com不匹配。