linux pulls the project from github and encounters Permission denied (publickey) locally. fatal: Could not read from remote repository.

problem

The following prompt is encountered when the favorite project is pulled locally:

Permission denied (publickey).
fatal: Could not read from remote repository.

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

Then you may want to clone a private project. In this case, you need to configure the key on Linux.

solution

linux generate ssh key

ssh-keygen -t rsa -C 邮箱

Insert picture description here
The following tips can use the default value if you don’t know what to set, that is, all the way Enterdown

If the default address is used above, enter

cd /root/.ssh

If you have filled in the address to save the key, enter the address you filled in

View key:

cat id_rsa.pub

Copy the contents to add on github later

add key on github

Two setting methods are provided, the latter is more reliable, and you can skip the first method if you don’t want to fork the project.

First fork the project on github. Then enter the project settings Setting, select Secrets in the left menu:
Insert picture description here
select on the right New repository secret, Valueand paste the secret key generated in the previous step in it:
Insert picture description here
Nameyou can fill in Add secretit at will, and you can use the following command to pull it later:

git clone 项目的ssh克隆地址

If the same error is reported after the above steps are executed, try to add an ssh key: enter personal setting->left menu bar and click SSH and GPG keys-"New SSH key-" name it, fill in the content in the generated document above . Just use the command to pull again
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44559752/article/details/109851961