2014年9月13日星期六

GIT push: permission denied (public key)

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  git@github.com:Sesamzaad/NET.git (fetch)
origin  git@github.com:Sesamzaad/NET.git (push)
any help is appreciated.
share|improve this question

3 Answers

Came across this question quite late but I was facing same problem. Here is what I did that worked for me.
Use ssh instead of http. Remove origin if its http.
git remote rm origin
Add ssh url
git remote add origin git@github.com:<username>/<repo>.git
Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.
cd ~/.ssh
ssh-keygen
Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.
cat ~/.ssh/id_rsa.pub
Add this key to your github account. Next do
ssh -T git@github.com
You will get a welcome message in your console.
cd into to your project folder. git push -u origin master now works!
share|improve this answer
I just had to deal with this issue. @user3445140's answer helped me, but was much more than I needed to do.
1. cat ~/.ssh/id_rsa.pub
2. copy the key, beginning with "ssh-rsa" but *excluding your computer name at the end*
3. Go to: https://github.com/settings/ssh
4. Add your SSH key
share|improve this answer

没有评论:

发表评论