Can't clone Git Repository, even I added Public Key to GIthub

Viewed 2186

I bought a new M1 Macbook Air, and I started to setup my on laptop. I installed Git, and I cloned my repository with

git clone git@github.com:xibotlab/homepage.git

Then there was an error:

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.

I knew that to solve this error I must add Git Public Key to Github, so I entered this:

ssh-keygen -t ed25519 -C "xibotmoon@gmail.com"

and I added Public Key to Github successfully.

But even I added Public Key, there was an error above. I searched on Github but I couldn't solve this problem, because all documents saids I must add Public Key, and I already did! How do I solve this?

Thank you.

1 Answers

Try first switching to HTTPS, especially for a public repository:

git clone https://github.com/xibotlab/homepage.git

Regarding SSH, test the SSH access first, before trying to clone:

ssh -Tv git@github.com

If you don't see a Welcome message, but the same Permission Denied error, you will have more debug information to investigate.

Related