bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A background ssh can take over the tty from bash?


From: Charles Daffern
Subject: Re: A background ssh can take over the tty from bash?
Date: Sun, 11 Jun 2017 18:43:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

>> But, from the man page:
>>
>>  -f      Requests ssh to go to background just before command execution.
>> This is useful if ssh is going to ask for passwords
>>              or passphrases, but the user wants it in the background.
>> This implies -n.  The recommended way to start X11 programs
>>              at a remote site is with something like ssh -f host xterm.
>>
>>              If the ExitOnForwardFailure configuration option is set to
>> “yes”, then a client started with -f will wait for all
>>              remote port forwards to be successfully established before
>> placing itself in the background.
>>
...
>>
>> Try:
>>
>> ​
>> ssh -f -o ControlMaster=no -o ControlPath=/tmp/socket.tmp 127.0.0.1 sleep
>> 9999
>>
> 
> Thanks but I want it to run as a background job in bash.
> 

That excerpt of the ssh man page provided above mentions the "-n"
option. Since ssh automatically sets that option for -f, you can safely
assume that it is somehow useful for backgrounded processes. Sure enough:

     -n      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 machine.  For example, ssh
             -n shadows.cs.hut.fi emacs & will start an emacs on
             shadows.cs.hut.fi, and the X11 connection will be auto‐
             matically 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.)

The -n option mentions that it "must be used when ssh is run in the
background", so I would recommend setting that on your backgrounded process.



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]