Ubuntu git pull 出现Permission denied Error

1.背景介绍

使用本地代码上传到github库的时候出现Permission denied 错误

$ git push -u origin main
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.

2.错误原因

由于重装系统,之前的配置信息都不存在了,所以SSL的认证信息需要重新建立。

2.解决方案

  1. 在系统执行下面命令
    $ ssh-keygen -t rsa -b 4096 -C "Your Email Address"
  2. 使用cat命令输出id_rsa.pub文件内的内容
    $ cat ~/.ssh/id_rsa.pub
  3. 拷贝cat输出的内容到github
    github的拷贝位置为github.com/settings/keys
    如果之前已经创建了SSH key,只需要添加一个新的就可以了

[Reference]
GitHub: Permission denied (publickey). fatal: Could not read from remote repository

本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!