Illegitimi non carborundum

Menu

Git over ssh on Mac/Linux. Private Key. No Password.

(Git is a software version control tool. It’s a software developer thing. Feel free not to read this if you don’t care about Git or software. I’m putting this up for the next poor yuck who’s got this problem and is praying to the Google gods for an answer.)

Here’s the problem.

I’m working on a web project. The web hosting service gives us access to the project on Git over an ssh (secure) connection.

The hosting company created and installed the ssh keys and gave us a copy of the private key. Then they disappeared. (Not really. They’re still there. But they live in India where there was a big holiday this week, so they weren’t answering email.)

I put my private key in the ~/.ssh directory. I fire up a terminal window. I type:

git pull ssh://git@git.hostingservice.com/projectname.git

The server asks for a password.

I don’t have a password. All I have is this key file. And they’re off the hook in India.

Here’s what you have to do.

In your ~/.ssh directory, look for a file called config. If you don’t have one, fire up your text editor and make a new one.

Technically, you can call the host (on the first line) anything you want. Call it george if you want. I’ve made it the same as the hostname because I use SublimeText with SublimeGit as my IDE, and SublimeGit always calls the Git Host by the Hostname. But if you’re just using the command line, anything goes.

One last thing. You have to check the permissions on the key file. When I first just dropped it into the ~/.ssh directory, it inherited the 0644 permissions of everything else. Ssh hates that. It will ignore keys that are open to the public. Set the key file’s permissions to 0600.

Now you’re good to go. From the command line, you can call Git and ssh into whatever you called the host:

Post navigation

One thought on “Git over ssh on Mac/Linux. Private Key. No Password.”

Dude, THIS IS WHAT SAVED ME. Thanks A TON for the advice! I kept trying to run a git pull, assuming it’d find the keys and I had it going on behind a POST hook so I had to . . . blah blah blah. Thanks so much!

Comments are closed.

About

Sunday Epidemic was a kind of "practice blog" where for a year I posted something every day.
Many thanks to the several readers and commenters throughout the year.
For updates after December 12, 2014, please check in at iCaspar.net.
Thanks,
Caspar Green