Proper way to use 'ssh-agent' and 'ssh-add' ?
Christopher Browne
cbbrowne-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Sat Feb 4 19:08:51 UTC 2006
On 2/4/06, William Park <opengeometry-FFYn/CNdgSA at public.gmane.org> wrote:
> What is proper way to use 'ssh-agent' and 'ssh-add'?
>
> Manpage says, 'ssh-agent' is to be run within login console, like
> eval `ssh-agent -s`
> and killed with
> eval `ssh-agent -s -k`
> If I put that in ~/.profile, then I have to type my passphrase on every
> login console or xterm. Very painful.
>
> I would like to run 'ssh-add' once, either at console or Xterm; and,
> after that, all my ssh activities should lookup 'ssh-agent', whether I'm
> at virtual consoles or Xterms.
Well, if I just plain run ssh-agent, I see the following output:
cbbrowne at knuth:~> ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-hIgcV30176/agent.30176; export SSH_AUTH_SOCK;
SSH_AGENT_PID=30177; export SSH_AGENT_PID;
echo Agent pid 30177;
Presumably, if I put those values into the environments of other shell
instances, then ssh, when invoked from those other shells, would be
able to access the ssh-agent running on PID 30177.
If I run the agent from the login shell, and invoke everything else
from that, those environment values would automatically be passed on,
and so, ssh-add would only need to get run once, *anywhere*.
I think, by putting the bald ssh-agent command into $HOME/.profile,
you're invoking it anew each time you start a new shell. You probably
need to instead check to see if SSH_AGENT_PID is set, and only invoke
it if there isn't already an ssh-agent running.
It might work out better if you put the command in $HOME/.bash_login;
that is not invoked for each new shell that you spawn...
--
http://www3.sympatico.ca/cbbrowne/linux.html
"The true measure of a man is how he treats someone who can do him
absolutely no good." -- Samuel Johnson, lexicographer (1709-1784)
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list