【问题标题】:Git is looking for a wrong SSH keyGit 正在寻找错误的 SSH 密钥
【发布时间】:2019-06-28 08:46:02
【问题描述】:

我决定尝试使用 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 键?

【问题讨论】:

  • ~/.ssh/config 存在吗?可能key里面是为github配置的。
  • @ElpieKay 是的!我真的不知道它是怎么发生的,但它是这样配置的。谢谢。

标签: git ssh


【解决方案1】:

看起来我的 ~/.ssh/config 配置不当:

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

我需要将 IdentityFile 更改为真实文件,在我的例子中,id_rsa

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

【讨论】:

    【解决方案2】:

    试试这个:

    ssh-add ~/.ssh/correct_key
    

    【讨论】:

      猜你喜欢
      • 2015-05-01
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      • 2017-09-29
      • 2011-02-19
      • 1970-01-01
      • 1970-01-01
      • 2021-06-06
      相关资源
      最近更新 更多