ubuntu github添加公钥 ,记录一下

echo "# depth_estimation" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/601480999/depth_estimation.git
git push -u origin master

报错了,错误如下:

Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
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.

问题解决:

  1. 删除  ~/.ssh  文件
  2. 生成公钥 : ssh-keygen -t rsa -C "和你gihub对应的邮箱" ,然后一直回车,回车,回车
  3. 验证:ssh -T [email protected]
    验证时候,会先出现
    The authenticity of host 'github.com (52.74.223.119)' can't be established.
    RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
    Are you sure you want to continue connecting (yes/no)? 
    

    输入yes


    不幸的是,仍然出现以下问题:
     

    Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
    sign_and_send_pubkey: signing failed: agent refused operation
    Permission denied (publickey).


    继续输入以下两行代码就ok了。
     

    eval "$(ssh-agent -s)"
    
     ssh-add
    

    这时候重新验证一下:
     

    ssh -T [email protected]
    

    出现以下内容:
     

    Hi (你的用户名字)! You've successfully authenticated, but GitHub does not provide shell access.
    

     

 

你可能感兴趣的:(ubuntu github添加公钥 ,记录一下)