MikiBelavista
MikiBelavista

Reputation: 2728

Why does git push works for one repo and doesn't work for the other? [email protected]: Permission denied (publickey)

I used GPG to set my Github access. I created new repo today and I encountered problems like this

git push origin main
Warning: Permanently added the RSA host key for IP address '140.82.999.4' to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Remote

git remote -v
origin  [email protected]:balboa/createreactapp.git (fetch)
origin  [email protected]:balboa/createreactapp.git (push)

Everything works fine from my other repo

git commit -m "signup changed"
[master b590077] signup changed
 3 files changed, 8 insertions(+), 5 deletions(-)

I am on Ubuntu 20.04.

How to solve permission for the new repo?

Upvotes: 0

Views: 69

Answers (1)

iceweasel
iceweasel

Reputation: 786

THis issue can be happened if you dont add your public key to ssh-agent after RSA key generation

First , Add your required public key ( ~/.ssh/id_rsa.pub ) to your github Account then ,

This problem can be solved by running these commands

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<required-key>.pub 

This will add your public key to ssh-agent and it wont show the error message of 'Could not read from remote repository.'

Upvotes: 2

Related Questions