Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Backgrounding part of 'ssh-agent $cmd'
- X-seq: zsh-users 17596
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Backgrounding part of 'ssh-agent $cmd'
- Date: Mon, 21 Jan 2013 05:58:26 +0200
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=mesmtp; bh= Qpemp+tdmPcupI6GrbTj29dQwmg=; b=MKK3ELwy8tnzPeoerTvIE9K7e82q2Dy5 Lm6eGIMsS46708ZxM3Cz81WTy1bBQu6qY2G0wR4OXOu5buv605DYIvz9gVPxlKfk 8XHMhFJgqnZxAwUzNoSmCprI8jaOvTRvq6qcLh+C6keOtaEoh+wshdTN85WgITti 0v8ENjQABpc=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=smtpout; bh=Qpemp+tdmPcupI6GrbTj29dQwmg=; b=iUlzEazHNwUAHxbmkoAPfzTpkf0z Aq54cVW8y5QVwyKi/6PMgn68J/oWsFsjkax3bGXvPjvJfUsbtCl6vtxfLSYV1bxI Ronp5BL107DaBdO1kcd/moiGNCYK91Ux6c1P8dqnLxMyZF+0s6QCSPONBiXWk3vZ OSgjbLCc/4ukwOM=
- In-reply-to: <130118073522.ZM24670@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20130116065951.GA2992@lp-shahaf.local> <130116093514.ZM19656@torch.brasslantern.com> <20130118061845.GC3024@lp-shahaf.local> <130117232602.ZM23841@torch.brasslantern.com> <20130118141322.GE4666@lp-shahaf.local> <130118073522.ZM24670@torch.brasslantern.com>
Bart Schaefer wrote on Fri, Jan 18, 2013 at 07:35:22 -0800:
> On Jan 18, 4:13pm, Daniel Shahaf wrote:
> >
> > The part that I find less than ideal so far is that, under load, the GUI
> > ssh-askpass dialog appears after foo_main has started.
>
> You could do it like this:
>
> ( # Subshell so caller's environment won't be changed; could instead
> # declare locals, but this is immune to changes in ssh-agent
> eval `ssh-agent`
> ssh-add ~/.ssh/foo.id_rsa
> {
> for h in host1 host2 host3; do
> ssh -MNf $h &
> done
> wait
> } always {
> ssh-agent -k
> } &
> )
>
> Then you don't have to background foo_ssh_preseed, and your preferred
> order of events is retained.
Thanks! This makes the ssh prompt textual again, while keeping the loop
backgrounded; that's perfect.
To summarise, now I have:
foo_ssh_preseed() {
if [ -S ~/.ssh/ControlPath/host1 ]
then
return
fi
zsh -fc '
# Subshell so caller"s environment won"t be changed; could instead
# declare locals, but this is immune to changes in ssh-agent
eval `ssh-agent | tee /dev/stderr`
ssh-add ~/.ssh/foo.id_rsa
{
for h in \
host1 host2 host3 \
; do
ssh -MNf $h &
done
wait
} always {
ssh-agent -k
} &
'
}
Which relies on ControlPath,ServerAliveInterval,IdentityFile being set
in ~/.ssh/config.
I also had the subshell use -f --- mainly because I didn't know of
anything else in my configuration would interfere with the always{}
block, but upon review I notice it has the side-effect of making the
enclosing function a valid /bin/sh function.
Thanks again.
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author