如何解决在homestead虚拟机中通过SSH Key 提交github失败报错!Permission denied (publickey)

先关联上远程的GitHub仓库,执行以下git 命令:

git remote rm origin
git remote add origin git@github.com:Eric-seven/sample.git
git push origin master

命令截图

发现在homestead虚拟机中报以下错误:
*Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.*
如何解决在homestead虚拟机中通过SSH Key 提交github失败报错!Permission denied (publickey)_第1张图片

先确保运行在你本机的虚拟机中的SSH Key 相关文件已经从本地电脑同步复制到对应的家目录下的.ssh文件夹中了。
然后将虚拟机中的SSH Key 添加到ssh-agent 中:

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

命令截图

然后将本地主机中id_rsa.pub 公钥中的内容复制出来。
再到GitHub中添加一个新的 SSH Key
如何解决在homestead虚拟机中通过SSH Key 提交github失败报错!Permission denied (publickey)_第2张图片

完成以上操作,再重新执行:

git push origin master

如何解决在homestead虚拟机中通过SSH Key 提交github失败报错!Permission denied (publickey)_第3张图片
successfully!

参考链接:
github 上的参考
如何解决在homestead虚拟机中通过SSH Key 提交github失败报错!Permission denied (publickey)_第4张图片

你可能感兴趣的:(Git,工具)