I've got my .bash_profile
set up to eval $(ssh-agent)
so I can quickly connect to servers. If I add ssh-add ~/.ssh/id_rsa_my_key
to my .bash_profile
as well, I'll have to type the ssh key passphrase in every terminal window, even if I didn't intend to use that terminal window for logging into a server.
I could create an alias to make it trivially easy to type the ssh-add ~/.ssh/id_rsa_my_key
line (so I don't have to stop my train of thought about what I'm trying to accomplish and think instead about how I named my key) but I still have to remember to do that before I ssh into a box.
I'm used to working in OS X, where all this is handled almost transparently by the Keychain, and I just ssh
away without having to think about access. I'd rather not have to change my mental habits, even though I'm now primarily working from a Windows box. In Windows the ssh-agent dies as soon as I
I'd also rather not do this with aliases or functions for ssh, if it can be avoided. I think that creating aliases and functions that replace normal commands and programs is a somewhat fragile and risky solution: if another problem comes up in the future for which the only solution is to replace ssh
then my alias or (more likely) function becomes yet more complex and brittle. Increasingly so the third time, etc. etc. Nonetheless, this may be the only solution. Furthermore, to be useful, the function would have to somehow first check whether the key had already been added, otherwise I'd be adding it every time I logged in, which would accomplish nothing.
Does ssh
have some setting to do this automatically? Is there some better solution than adding ssh-add ~/.ssh/id_rsa_my_key
to my .bash_profile
?