From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Backgrounding part of 'ssh-agent $cmd'
Date: Wed, 16 Jan 2013 08:59:51 +0200 [thread overview]
Message-ID: <20130116065951.GA2992@lp-shahaf.local> (raw)
tldr: I have a piece of code that prompts for password and then
establishes N ssh connections in the foreground, and I'd like the
SSH connections to be established in the background.
More specifically, my workflow involves establishing several 'ssh -MNf'
connections every morning, and running a command that prompts for
a password:
foo_ssh_preseed() {
ssh-agent sh -x -e -c '
ssh-add ~/.ssh/foo.id_rsa
for h in host1 host2 host3; do
ssh -MNf $h &
done
wait
ssh-add -D'
}
foo_main() {
foo_ssh_preseed # the workaround places an 'if' around this line
foo_internal # prompts for password; is interactive/long-running
}
Right now, what happens is:
ssh-add prompts for password
I wait while SSH connections are being established
foo_internal prompts for password
I can avoid the delay by running foo_ssh_preseed() in a new terminal
emulator tab; or by running it directly in the same tab, ^Zing it, and
then running foo_internal (while foo_ssh_preseed is doing its work).
I'd like to remove the complication of an extra tab or explicit ^Z:
I'd like the workflow to be
Run foo_main
Answer ssh-add password prompt
# No interactive wait at this point.
Answer the foo_internal password prompt
(Use foo; the -MNf's will finish in a second or two.)
Thoughts?
Thanks,
Daniel
next reply other threads:[~2013-01-16 7:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 6:59 Daniel Shahaf [this message]
2013-01-16 17:35 ` Bart Schaefer
2013-01-18 6:18 ` Daniel Shahaf
2013-01-18 7:26 ` Bart Schaefer
2013-01-18 14:13 ` Daniel Shahaf
2013-01-18 15:35 ` Bart Schaefer
2013-01-21 3:58 ` Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130116065951.GA2992@lp-shahaf.local \
--to=d.s@daniel.shahaf.name \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).