Mac – Permission denied (publickey) – Cannot not read from remote repository

I tried cloning my project from github. I am getting the following error in my mac during the cloning process.

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

i have already added the ssh key to my github account .

>Solution :

Try following these steps

Step 1:

create a new ssh key:-

ssh-keygen -t ed25519 -C "your_email@example.com"

Step 2:

copy the ssh key on clipboard :-

pbcopy < ~/.ssh/id_ed25519.pub 

Step 3:

now paste copied ssh key to the corresponding git repository

Step 4:
Start the ssh-agent in the background.

$ eval "$(ssh-agent -s)"
> Agent pid 59566

Step 5:
now try accesing the repo

git clone git@github.com:username/repo-name.git

Step 6:

if still you see the issue then check the ssh config file

vim ~/.ssh/config

the content should look like

Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

Step 7:

Add your SSH private key to the ssh-agent and store your passphrase in
the keychain

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Step 8:

Now try again it should work

git clone git@github.com:username/repo-name.git

Leave a Reply