Linux——使用github提示错误Please make sure you have the correct access rights and the repository exists.

た 入场券 2022-11-20 09:42 437阅读 0赞

文章目录

    1. 问题描述
    1. 解决方法
    • 2.1 设置用户信息
    • 2.2 删除旧配置文件
    • 生成配置文件
    • 登记KEY
  • 测试

1. 问题描述

今天在使用git clone命令时出现了下面的提示

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

很懵呀,以前都没遇到过,谷歌了下,发现是SSH KEY的问题,需要重新添加KEY才阔以,解决方法如下。

2. 解决方法

2.1 设置用户信息

打开一个命令窗口,输入:

  1. git config --global user.name "yourname"
  2. git config --global user.email"your@email.com"

注:yourname是你要设置的名字,your@email是你要设置的邮箱。

2.2 删除旧配置文件

删除.ssh文件夹文件夹,通常是在/home/用户名/目录下,例如

  1. sudo rm -rf /home/lanx/.ssh/

其中lanx是我自己的用户名,需要根据自己的需要修改。

生成配置文件

  1. ssh-keygen -t rsa -C "your@email.com"(请填你设置的邮箱地址)

接着出现:

  1. Generating public/private rsa key pair.
  2. Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):

根据提示直接按下回车即可。之后系统会自动在/home/lanx/.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub

登记KEY

浏览器上打开https://github.com/,登陆自己的账户,进入设置后,选择ssh设置
在这里插入图片描述然后选择添加SSH Key
在这里插入图片描述
用记事本打开id_rsa.pub,

  1. vim /home/lanx/.SSH/id_rsa.pub

将里面的内容复制到上图中下方的Key框中,并点击Add SHH key按钮即可。

测试

重新打开一个命令窗口,即可使用。

发表评论

表情:
评论列表 (有 0 条评论,437人围观)

还没有评论,来说两句吧...

相关阅读