Git寻找错误的SSH密钥

时间:2019-06-28 08:46:02

标签: git ssh

我决定尝试使用SSH与GitHub存储库一起使用。我在git / .config中修改了远程URL,所以现在它使用SSH:

[remote "origin"]
        url = git@github.com:keddad/passpoint_server.git
        fetch = +refs/heads/*:refs/remotes/origin/*

但是,例如,当我运行 git fetch 时,git正在寻找错误的密钥:

(venv) keddad@keddad-pc:~/PycharmProjects/passpoint_server/.git$ git fetch
no such identity: /home/keddad/.ssh/github_rsa: No such file or directory
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

与此同时,添加到GitHub的真实密钥在文件〜/ .ssh / id_rsa 中 如何使git使用 id_rsa 键?

2 个答案:

答案 0 :(得分:3)

好像我的〜/ .ssh / config配置不当:

Host github.com
  IdentityFile ~/.ssh/github_rsa
  IdentitiesOnly yes

我需要将IdentityFile更改为真实文件,在我的情况下为 id_rsa

Host github.com
      IdentityFile ~/.ssh/id_rsa
      IdentitiesOnly yes

答案 1 :(得分:1)

尝试一下:

ssh-add ~/.ssh/correct_key