I’ve been having this ongoing argument with my test environment over my github ssh key. First it was just when I used a particular dev housekeeping script my project needs, but now every time I log out of a shell, my github ssh key goes missing. I have to remember to ssh-add before I want to do something involving github.

I tracked down the problem to ssh-agent, which apparently works fine for most people but for me requires constantly adding my key back. I found a solution by installing a keychain package for Ubuntu.

I already had my key, so I only had to install the package and add the appropriate configuration to my .bashrc. Now, at login, ssh-agent is started if needed, and my github ssh key added. I can logout and login all I like, access github from my shell, and only re-enter my passphrase if I reboot the machine. (I haven’t tested that part yet.)

I had started to wonder why I had bothered with an ssh key in the first place. But with this, it now works as expected. So much nicer.

2 Comments

  1. Chas. Owens says:

    Huh, that is odd, normally ssh-agent is used to start the window manager/desktop environment so all keys for that session only have to be entered once. Is it possible that you are starting up a second instance of ssh-agent in your .bashrc, .bash_profile, .profile, etc? That would explain the behavior you are seeing.

  2. feorlen says:

    Not that I can tell, I don’t even have a .profile for that login and the others don’t have anything that looks likely. One thing I did notice with the current setup, is if I do sudo bash it starts a second one. That messes it up again. Sometime I’ll have to look into it again. It’s now down to an occasional nuisance, so I haven’t bothered.

Leave a Reply