I’m Paul Herron and I’m a web developer. I build online applications
with tools like CakePHP and jQuery.

Permanently adding an SSH identity on OS X

by Paul Herron on 01 June 2014

I just found a useful option on the ssh-add command on the Mac. I have quite a few keys in my ~/.ssh directory, including an id_bitbucket one for my BitBucket account. For a while now after rebooting I'd been getting an error when trying to use it:

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

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

It turns out this is easily fixed using the ssh-add command:

ssh-add ~/.ssh/id_bitbucket

… but by default this won't persist after a reboot. The fix for that is to use the -K flag to add it to your keychain:

ssh-add -K ~/.ssh/id_bitbucket

No more annoying errors after a reboot! Makes me wish I'd read the manual earlier.

Back to homepage

Next: