美文网首页
解决github连接远程仓库上传代码时因缺少SSH Key出现没

解决github连接远程仓库上传代码时因缺少SSH Key出现没

作者: Alexa_老王 | 来源:发表于2020-09-08 13:49 被阅读0次

    报错信息如下:
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    原因:
    Permission denied (publickey) 没有权限的publickey ,出现这错误一般是以下两种原因
    1、客户端与服务端未生成 ssh key
    2、客户端与服务端的ssh key不匹配

    解决方法:
    打开cmd命令行工具或者使用git提供的命令行工具 ‘Git bash here’
    1、ssh-keygen -t rsa -C "你的邮箱地址",途中会让你输入密码啥的,不需要管,一路回车即可,会生成你的ssh key
    2、ssh -v git@github.com
    按下回车后,命令行工具最后两行代码 参照对比
      No more authentication methods to try.
      Permission denied (publickey).
    3、ssh-agent -s
    4、ssh-add ~/.ssh/id_rsa
    Identity added 后面的路径就是刚刚生成的ssh key文件路径的信息
    5、打开你刚刚生成的id_rsa.pub,将里面的内容复制,进入你的github账号,在settings下,SSH and GPG keys下new SSH key,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。

    验证 SSH Key
    ssh -T git@github.com

    相关文章

      网友评论

          本文标题:解决github连接远程仓库上传代码时因缺少SSH Key出现没

          本文链接:https://www.haomeiwen.com/subject/qjwdektx.html