Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
在通过命令:
1. ssh-keygen -t rsa -b -C "mymeil@qq.com"
2. 一路回车
3. eval "$(ssh-agent -s)" // 创建一个 ssh-agent
4. ssh-add ~/.ssh/id_rsa
$ ssh -T git@github.com
> Hi username! You've successfully authenticated...
没有问题后,通过 git 向仓库提交仍报错:
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
然后发现这篇文章:
git 指定sshkey访问远程仓库
于是我按照步骤重新执行 ssh-keygen,专门为 github 使用的 rsa 起了一个文件名:
1. ssh-keygen -t rsa -b -C "mymeil@qq.com"
2. > Enter file in which to save the key (/home/dujinqiao/.ssh/id_rsa): /home/dujinqiao/.ssh/git-ssh
// 给 github 用的 rsa 就是 git-ssh,不设密码,继续回车
3. eval "$(ssh-agent -s)" // 创建一个 ssh-agent
4. ssh-add ~/.ssh/git-ssh
5. vi ~/.ssh/config // 没有 config 就创建一个
编辑 >
Host obligat.github.com // 名字随便起
User git // 固定写法
IdentityFile /home/dujinqiao/.ssh/git-ssh // 刚才指定的路径
IdentitiesOnly yes // 只从指定文件读取 RSA,不使用默认的
最后,使用 git 成功提交。