[patch] Re: -n vs batch_mode vs batch_flag

Wayne Davison wayne at blorf.net
Tue Apr 10 03:18:41 EST 2001


On Mon, 9 Apr 2001, Markus Friedl wrote:
> Redirects stdin from /dev/null (actually, prevents reading from
> stdin).  This must be used when ssh is run in the background.  A
> common trick is to use this to run X11 programs on a remote ma-
> chine.  For example, ssh -n shadows.cs.hut.fi emacs & will start
> an emacs on shadows.cs.hut.fi, and the X11 connection will be au-
> tomatically forwarded over an encrypted channel.  The ssh program
> will be put in the background.  (This does not work if ssh needs
> to ask for a password or passphrase; see also the -f option.)

I think this could be improved a bit.  The problems I have with it:

  - It should say explicitly that it doesn't stop authentication prompts.
  - Someone reading too casually might think that ssh puts the program
    into the background, not the shell.
  - A better explanation for why -n and prompts don't work well
    together is needed (since -n works just fine with prompting, it's
    the backgrounding by the shell that makes it not work right).

The following patch improves this section on -n, and makes a slight
tweak to the -f section.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: ssh.1
@@ -399,8 +399,9 @@
 to go to background just before command execution.
 This is useful if
 .Nm
-is going to ask for passwords or passphrases, but the user
-wants it in the background.
+is going to ask for passwords or passphrases (since it needs to be
+in the foreground for that), but the user
+wants the command to be run in the background.
 This implies
 .Fl n .
 The recommended way to start X11 programs at a remote site is with
@@ -437,6 +438,7 @@
 Redirects stdin from
 .Pa /dev/null
 (actually, prevents reading from stdin).
+Does not prevent authentication prompts (which get read from /dev/tty).
 This must be used when
 .Nm
 is run in the background.
@@ -447,12 +449,13 @@
 connection will be automatically forwarded over an encrypted channel.
 The
 .Nm
-program will be put in the background.
-(This does not work if
+program will be put in the background by the shell (because of the '&').
+This shell idiom does not work well when
 .Nm
-needs to ask for a password or passphrase; see also the
+needs to ask for a password or passphrase (because ssh will block
+waiting for a foreground response from the user); see the
 .Fl f
-option.)
+option for a way to solve this.
 .It Fl N
 Do not execute a remote command.
 This is useful if you just want to forward ports
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---




More information about the openssh-unix-dev mailing list