0 votes
1 view
in Devops and Agile by (19.8k points)

GIT: I'm trying to push a file to a repo of a friend but errors on public key.

git push origin testbranch

Permission denied (publickey).

fatal: Could not read from remote repository.

Where and how do we define public / private keys?

git remote -v returns:

origin  [email protected]:Sesamzaad/NET.git (fetch)

origin  [email protected]:Sesamzaad/NET.git (push)

any help is appreciated.

1 Answer

0 votes
by (63.4k points)

I was facing the same problem, here is what I did that worked for me.

  1. Use ssh instead of http. Remove origin if its http.

git remote rm origin

2. Add ssh url

git remote add origin [email protected]:<username>/<repo>.git

3.Generate ssh key inside .ssh/ folder. It will ask for passphrase and path where you can just press enter and proceed.

cd ~/.ssh

ssh-keygen

    4. Now, copy the key. You can view your key using. If you hadn't specified a different path then this is the default one for you to use.

cat ~/.ssh/id_rsa.pub

5. Add this key to your Github account. Next, do

ssh -T [email protected]

You will get a welcome prompt in your console.

cd into to your project folder. git push -u origin master now works!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...