解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

出现这种错误一般是你的密钥错误,需要重新生成。

  1. 在windows的任意路径打开bash, 然后输入命令ssh-keygen -t rsa -C 邮箱地址
    默认生成的密钥在/c/Users/用户名/.ssh
    解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
  2. 查看公钥
    解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
  3. 复制公钥进入github
    进入仓库,点击Setting -> Deploy Keys -> Add new,粘贴公钥进入key输入框,勾选允许push,最后点击add key 按钮提交。
    解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
  4. 测试,输入命令 ssh -T git@github.com,出现以下提示就证明ssh配置成功了。

解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
5. 本地仓库配置远程仓库地址
进入github,点击code,选择SSH,复制ssh的链接。
解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
输入命令 git remote add 仓库名 ssh地址
然后校验是否配置成功,输入 git remote -v. 出现以下提示则配置成功
解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
6. 测试远程仓库,输入命令 git push 远程仓库名 master
命令表示将本地仓库所有的提交文件推送到远程仓库AUMS的master节点
出现以下提示则表示推送成功。
解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
7. 进入github点击branch, 默认的是main,这里需要点击以下master下拉列表来切换到master分支,
解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
8. 这里出现了我刚提交的ReadMe.md文件,说明整个配置以及提交操作成功。
解决错误 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

上一篇:spring 注解


下一篇:可以在打开的文件句柄上使用Linux inotify吗?