Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

I got 'permission denied(publickey)' when I typed 'git push origin master'!

Here's the error message on cmd[Windows7] git push origin master Permission denied (publickey). fatal: Could not read from remote repository.

I had deleted and recreated Ruby on Rails, and received that error. I guess it was caused by the difference of my old public SSH key.. Please help me! I'd greatly appreciate your help! thanks!

PS. [after I deleted my previous .ssh folder, it automatically recreated a new RSA key. and I still could not access...]

c:\Projects\treebook>git push -u origin master The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of know n hosts. Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

3 Answers

James Barnett
James Barnett
39,199 Points

Try removing the local repo and re-adding it:

git remote rm origin git remote add origin <remote url>

source: http://kirk.vangorkom.org/github-permission-denied-publickey-error-work/

Oh O.o I deleted the local repo and followed your instruction, but still I am stuck here.

c:\Projects\treebook>git remote remove origin

c:\Projects\treebook>git remote add origin git@github.com:geekerati/treebook.git

c:\Projects\treebook>git push -u origin master Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

I solved this problem by using the https url, 'https://github.com/geekerati/treebook.git', not with 'git@github.com:geekerati/treebook.git'. it's weird .. O.o;; but Thanks!

James Barnett
James Barnett
39,199 Points

Dongju Seo - The SSH method of pushing/cloning repos has been depreciated.

Github now recommends you always use the HTTPS method that you used. That way you don't to configure SSH keys thus removing that layer of complexity.

Have you run heroku keys:add in the console yet? That solved it for me when I had the same issue.

I am having the same issue and I tried to use the command

git remote rm origin git remote add origin <remote url>

,but it tells me

the syntax of the command is incorrect

I also tried git remote add origin using the https method, but I keep getting the same results and it also tells me that the remote origin already exists.

Can anyone suggest what I should do at this point?

What is the same issue exactly? Can you show me what you were trying to achieve and the errors?

Please write your question on the forum and provides me the link.

I was following along with the video and I was trying to push treebook to github when I received

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

Please make sure you have the correct access rights and the repository exists."

I tried the solution listed in this forum and it did not work.

I tried git remote rm origin git remote add origin <remote url>

and I received "usage: git remote remove <name>".

I then tried "git remote add orgin <remote url>"

and I received "fatal: remote origin already exists".

When I tried "git push -u origin master"

I received "permission denied (public key) fatal: could not read from remote repository"

The command, "git remote rm origin git remote add origin" is not correct. Try this to delete your remote origin key, "git remote remove origin" Then conduct this command too to readd your remote origin key, "git remote add origin 'your git https url'"

let me know whether you have solved that issue or still remained.

I am still having the same issue. Here is a link that has a screenshot of what I am getting

http://postimg.org/image/kondib9ip/

Pleas follow below them again..

git init git remote remove origin git remote add origin 'your git https url' git push -u origin master

If this does fail again, follow this link here https://help.github.com/articles/generating-ssh-keys#platform-windows

Thanks Dongju,

I finally got it to work when I typed "git remote add origin https://github.com/username/treebook" and then I typed "git push -u heroku master".

I think the problem was that I used "git remote add origin https://github.com/username/treebook.git"

Yay! I am glad that you got it work! 'git remote add origin' is not the cause of the error. I think the cause was you typed a different username. When you created a user, your user was not 'origin'.