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

Development Tools

Josie Nagy
Josie Nagy
14,992 Points

Github Error

Hi everyone!

I was trying push my first project to Github, but took a short break, my Treehouse console timed out and now I'm getting this message after trying to continue:

Permission denied (pubkey)

What does this mean more exactly? How do I fix this?

Any advice would be helpful, thank you!

2 Answers

Michael Hulet
Michael Hulet
47,913 Points

You've told git to talk to your remote repository (the one on GitHub) using SSH. SSH is a protocol to securely interact with remote computers. With SSH, you generate 2 keys: a public key that you can share with anyone you want, and a private key that you always protect and keep to yourself. To access a remote server (like GitHub) with SSH, you give it your public key ahead of time, and when you attempt to log into the remote computer, it checks to make sure you have the corresponding private key.

GitHub lets you access your repositories in 2 ways: over SSH and over HTTPS. In this case, you're attempting to access your remote repository over SSH, and you're working inside of a Treehouse Workspace, which doesn't appear to have your private key. Usually, you want to use SSH over HTTPS because it's ultimately a bit more secure, but more importantly you never want your private key to leave your computer. That means you definitely should not upload it to any server, including Treehouse Workspaces. In this case, you want to tell git to talk to your remote repository over HTTPS instead. You can do this by changing your URL to an HTTPS one instead of SSH, like this:

git remote set-url origin https://github.com/Josie-N/Treehouse.git

Once you do that, you should be able to use git and GitHub normally

Josie Nagy
Josie Nagy
14,992 Points

Thank you so much Michael, I never knew that and I'm grateful you took the time to explain it to me. I'm glad I asked (and that you replied), learned something really important.

Ari Misha
Ari Misha
19,323 Points

Hello there! I just answered a similar question right here. You probably have to provide SSH keys in order to let Github recognize you. Be sure to read the answer on the above link. I hope it helped!

~ Ari

Michael Hulet
Michael Hulet
47,913 Points

This is a really helpful answer if you're working locally, and not with Workspaces. Seriously, though, I can't stress enough how bad of an idea it is to use SSH with Git on Workspaces. Only do that with your local machine. You really want to use HTTPS in this case

Ari Misha
Ari Misha
19,323 Points

@MichaelHulet Couldn't agree more?!