0

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 .

  • 1
    i tried most of the solution given but in rahul's answer step 7 i.e :- ssh-add --apple-use-keychain ~/.ssh/id_ed25519 fixed my issue – Shivangi Gupta Aug 15 '23 at 20:54

1 Answers1

0

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 the 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 accessing 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
officialrahulmandal
  • 2,473
  • 1
  • 23
  • 31
  • Basically identical to the GitHub help docs. – matt Aug 15 '23 at 20:41
  • It's also a copy paste across [several](https://stackoverflow.com/questions/21255438/git-permission-denied-publickey-fatal-could-not-read-from-remote-repository/76908542#76908542) [other](https://stackoverflow.com/questions/2643502/git-how-to-solve-permission-denied-publickey-error-when-using-git/76908495#76908495) questions. – Kevin B Aug 15 '23 at 20:46
  • yeah, the answer is inspired by GitHub help docs but I have simplified the steps by adding some additional steps to make it more understandable sir. – officialrahulmandal Aug 15 '23 at 20:49
  • since when I read the same there was so much information and it took me time to understand the same so thinking of a person who wants an urgent solution I have curated this which is easy to understand for a quick fix . is there I can improve in this answer sir..? – officialrahulmandal Aug 15 '23 at 20:51