我决定尝试使用 SSH 来处理我的 GitHub 存储库。我修改了 git/.config 中的远程 url,所以现在它使用 SSH:
[remote "origin"]
url = git@github.com:keddad/passpoint_server.git
fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
但是,例如,当我运行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.
Run Code Online (Sandbox Code Playgroud)
同时,添加到 GitHub 的真正密钥位于~/.ssh/id_rsa文件中 如何让 git 使用id_rsa密钥?
看起来我的 ~/.ssh/config 配置不正确:
Host github.com
IdentityFile ~/.ssh/github_rsa
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
我需要将 IdentityFile 更改为真实文件,在我的例子中为id_rsa
Host github.com
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)