Solve the error reported by git clone on linux [email protected]: Permission denied (publickey). Could not read from remote repo

Error details:

I saw an interesting project on gitee today, so I wanted to download it for research. As a result, an error was reported when git clone was cloned. The error was as follows:

[email protected]: Permission denied (publickey).fatal: Could not read
from remote repository. Please make sure you have the correct access
rights and the repository exists.

insert image description here

Cause Analysis:

Permission denied (publickey) does not have permission for the publickey (public lock), there are generally two reasons for this error:

  • The client and server did not generate ssh key
  • The ssh key of the client and the server does not match

Finally, the cause of the problem was found, because the public and private keys were not set correctly, resulting in no permission to operate. So you need to generate an ssh key once, and the server also needs to be configured;

Solution:

  • 1. First check whether you have generated a public key
cat ~/.ssh/id_rsa.pub 

If there is, it should ssh-rsastart with and end with the email address registered when generating the public key.

insert image description here

I took a look, and there is a public key here, so why is there an error? I checked the mailbox, because this former colleague is also using it, it may be the public key generated by him, and the email address is his; so it is because It’s a different mailbox, that is, two accounts, so it can’t be used, but we need to know the password at the time of setting, otherwise we can’t get it. Simply, I regenerated one. Note: when generating the public key again here, it will Overwrites previous ones, so back up before regenerating if necessary.

  • 2. Generate public and private keys
ssh-keygen -t rsa -C[email protected]

Here [email protected] fill in your own email account;

insert image description here

  • 3. Add the public key to Code Cloud

Copy the public key you just generated:

cat ~/.ssh/id_rsa.pub 

insert image description here

Open your own Gitee settings –> ssh public key: https://gitee.com/profile/sshkeys

insert image description here
insert image description here

insert image description here

Then you need to do a security authentication, you need to enter the password of gitee, and finally the addition is successful.

  • 4. You can verify whether it is successful by yourself
ssh -T [email protected]

Here you need to enter the password when you set up the public key; if it appears at the end, accessit will be successful.

insert image description here

  • 5. Then we can clone the warehouse
git clone [email protected]:carefree-state/mara-circle-july-2023.git

insert image description here

In this way, the clone is successful.

insert image description here

Guess you like

Origin blog.csdn.net/liu_chen_yang/article/details/131652500