Re: using "at" and ssh
- From: John Wingate <johnww@xxxxxxxxxxxxx>
- Date: Sat, 31 Dec 2005 17:05:25 -0000
Cloud Burst <DoNotReplyViaEmail@xxxxxxxxxxx> wrote:
> So let's say I do this and come back the next day. My job ran fine,
> but now there is this ssh-agent running that I can't use for anything,
> right? According to the ssh-add man page (and I tried) I can't use a
> new ssh-add against this old ssh-agent. I have to start a new agent.
You don't have to start a new agent. You can use the old agent if you
have saved the relevant environment variables in a file so they can be
read by your new shell. A few lines in my .bash_profile do this, along
with a check that the agent still exists:
# Save ssh-agent environment variables in a file
# so that they can be read by processes not inheriting
# this environment; e.g., those started by cron.
# But don't start more than one agent, so check first.
[ -f $HOME/.ssh-agent ] && . $HOME/.ssh-agent
if ! ssh-add -l >/dev/null 2>&1
then
ssh-agent | head -2 >$HOME/.ssh-agent
. $HOME/.ssh-agent
fi
If the data in $HOME/.ssh-agent is stale (i.e., the corresponding agent
is dead), ssh-add will return an error and a new agent will be started.
Scripts (started by cron, for example) just have to read in the
environment variables to be able to contact the agent, with a line
like:
. $HOME/.ssh-agent
(with perhaps a check for a dead agent as above and suitable error
handling).
--
John Wingate Mathematics is the art which teaches
johnww@xxxxxxxxxxxxx one how not to make calculations.
--Oscar Chisini
.
- Follow-Ups:
- Re: using "at" and ssh
- From: Anonymous
- Re: using "at" and ssh
- References:
- using "at" and ssh
- From: RR
- Re: using "at" and ssh
- From: Anonymous
- using "at" and ssh
- Prev by Date: Path Problems with 4.2p1?
- Next by Date: Re: Path Problems with 4.2p1?
- Previous by thread: Re: using "at" and ssh
- Next by thread: Re: using "at" and ssh
- Index(es):
Relevant Pages
|
|