Failure is inevitable


Fun with Git: how to re-attach your ssh key on a new machine

It seems you are no longer cool unless you are using Git and Github, so I decided I’d give it a shot with Esenterate.  I found Git for Windows Developers to be extremely useful, and I highly recommend reading it if you are thinking about using Git. 

Everything was fairly straight forward except for one small detail: I wanted to use Git from both my laptop and my desktop.  I generated my public/private key pair on my laptop, then copied it to my desktop, but I wasn’t sure how to associate the pair with my user in gitbash.  (yes, I realize that the solution is probably obvious to all you *nix peeps out there; go back to editing your 10,000 config files, please. *smiles*)  Without this key correctly associated to your account, you won’t be able to push to Github.  After some Googling, I discovered the ssh-add command.  Unfortunately, I couldn’t get it to work.  I kept getting Could not open a connection to your authentication agent errors.  After even more Googling, I found the solution: you need to start ssh-agent, then execute the ssh-add command, like so:

exec ssh-agent bash
ssh-add id_rsa

If everything goes according to plan, you should see a success message like Identity added: id_rsa (id_rsa).  You should now be all set to push to Github!

About Matt Honeycutt...

Matt Honeycutt is a software architect specializing in ASP.NET web applications, particularly ASP.NET MVC. He has over a decade of experience in building (and testing!) web applications. He’s an avid practitioner of Test-Driven Development, creating both the SpecsFor and SpecsFor.Mvc frameworks.

He's also an author for Pluralsight, where he publishes courses on everything from web applications to testing!

blog comments powered by Disqus