How can I avoid always having to use `eval 'ssh-agent -s'`
As @Jakuje said, using Forward Agent and using a key on your local, secure machine is better.
However, if you need to do what you say, use a tool such as keychain
(github.com/funtoo/keychain) or ssh-find-agent
(github.com/wwalker/ssh-find-agent ( I wrote the latter, and many still use it, but I have since switched to using the former ). Both of these tools look for running gpg or ssh agents and connectyour environment up to them for you.
Related videos on Youtube
horatio1701d
Updated on September 18, 2022Comments
-
horatio1701d almost 2 years
I can't figure out why everytime I ssh back into my server I always have to start my ssh agent with the command
eval 'ssh-agent -s'
followed byssh-add <my_key.pem>
in order to successfully ssh from my server. I have placed this in my .bashrc but obviously I'm missing something and don't want to always have to initialize that each time I log in.-
YoloTats.com over 8 yearsMaybe a ssh-reagent script may help you?
-
YoloTats.com over 8 yearsYou need to call the ssh-reagent() function (the gist only define it). There need also already a ssh-agent running.
-
horatio1701d over 8 yearsThanks again for this. I called it from my bashrc and seems to work now but i noticed a ton of ssh-agent processes running after that. Is there a way to just re-use same process?
-
YoloTats.com over 8 yearsAre you sure, that the the ssh-agent did not run previously? The ssh-reagent script does not start new ones.
-
-
Julian Cienfuegos almost 7 yearsI wonder what I did.... I had this issue when I set up ssh for my github account. Then I set up ssh for my digital ocean droplet and after doing ssh-copy-id, ssh-add, and then connecting to my webserver, the issue went away. I just restarted my computer and miraculously I don't have to start the agent any more. WEIRD
-
clay over 3 yearsNot my choice cause I have hundreds of repos and do not put them to my ssh config ~/.ssh/config
-
clay over 3 yearsNot my choice cause I have hundreds of repos and do not put them to my ssh config ~/.ssh/config