Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keychain for ssh-add [closed]

I need to pull from Github all the time and I have a passphrase, but it's a pain, so I typically run...

ssh-agent bash
ssh-add ~/.ssh/id_rsa
<prompt and give passphrase>

And that works for the session, but even after I logout, I would like it to save the passphrase next time I PuTTY in. So I installed keychain, but I'm too dumb to operate it. I tried this...

/usr/bin/keychain ~/.ssh/id_dsa

And it said it added my passphrase, but it didn't work :(

How would I call keychain so it saves my passphrase for Git?

Edit: Apologies for posting this on stackoverflow, it technically does have some relevance to programming as it has to do with Git, but my apologies for not posting it on SuperUser.

like image 849
TheFrack Avatar asked May 16 '12 16:05

TheFrack


3 Answers

You actually need to invoke keychain differently. Add the following to your ~/.bashrc file:

eval `keychain --eval id_rsa`

See the keychain documentation for more information about how to set it up properly for your specific shell or system, or if you have more complex requirements.

like image 170
Todd A. Jacobs Avatar answered Sep 30 '22 13:09

Todd A. Jacobs


Okay this is the best I could come up with...

Install keychain...

Then add the following to ~/.bashrc file:

eval `keychain --eval id_rsa`

THEN add the following to ~/.bash_profile:

ssh-agent bash

That will start keychain. It isn't as simple as just putting both in the bash profile or bashrc file.

like image 33
TheFrack Avatar answered Sep 30 '22 13:09

TheFrack


You have to keep the keys in a "persistent" state so to say. This can be done by having an agent open one on the local side, combined with — in case of openssh — ssh -A. Then, ssh-add on the remote server will cause the keys to be opened and retained on the local desktop, such that, when logging in again on the remote side, the keys are already available.

like image 44
jørgensen Avatar answered Sep 30 '22 13:09

jørgensen