• Git push提交时报错Permission denied(publickey)...Please make sure you have the correct access rights and the repository exists.


    一、git push origin master 时出错
    错误信息为: Permission denied(publickey).

    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

    可能:
    可能没联网
    可能没配置好.git/conf文件
    可能是与github上的账号没建立密钥对

    二、解决办法
    配置文件: 进入你的仓库,下面有个.git目录里面有conf配置文件,直接vim .git/conf 修改成如下:如果不是git提交是https方式,url和pushurl自己改成自己仓库的地址就好
     11 
     12 [remote "origin"]
     13     url = git@github.com:s--enten--/--an.git
     14     fetch = +refs/heads/*:refs/remotes/origin/*
     15     pushurl = git@github.com:s--enten--/--an.git.git
     16 [branch "master"]
     17     remote = origin
     18     merge = refs/heads/master  
    

    建立密钥:

    1. ssh-keygen -t rsa -C "youremail@example.com"

      注意,上述youremail@example.com是指github账户的注册邮箱

    2. ssh -v git@github.com

      上述命令执行后,出现的提示最后两句是

      No more authentication methods to try.

      Permission denied (publickey).

    3. ssh-agent -s

      上述命令执行后,出现的提示最后两句是

      SSH_AUTH_SOCK=/tmp/ssh-GTpABX1a05qH/agent.404; export SSH_AUTH_SOCK;

      SSH_AGENT_PID=13144; export SSH_AGENT_PID;

      echo Agent pid 13144;

    4. ssh-add ~/.ssh/id_rsa

      上述命令执行后,出现提示

      Identity added: . . . (这里是一些ssh key 文件路径)

      Could not open a connection to your authentication agent.

    5. 若第4步中出现上述提示,则执行此步骤,否则执行6

      eval 'ssh-agent -s'

      ssh-add ~/.ssh/id_rsa

    6. vim ~/.ssh/id_rsa.pub

      上述命令执行后id_rsa.pub文件内容将输出到终端,复制里面的密钥(内容一般是以ssh-rsa 开头,以github账号的注册邮箱结尾的,全部复制下来)

    7. 进入github账号,在settings下,选SSH and GPG keys, 点击new SSH key
      以下可参考这篇博客

  • 相关阅读:
    c++中的内存管理【转载】
    c++中dynamic_cast、static_cast、reinterpret_cast和const_cast作用
    c++中的顶层const和底层const
    c++赋值操作符需要确保自我赋值的安全性问题
    二分法查找
    Servlet基础总结
    java 正则表达式:有丶东西
    HTTP协议初步认识
    Java synchronized到底锁住的是什么?
    ECMA Script 6新特性之解构赋值
  • 原文地址:https://www.cnblogs.com/shiqi17/p/9446338.html
Copyright © 2020-2023  润新知