Remote ssh tunnel in background or script?

Kevin Kinsey kdk at
Mon Nov 9 20:48:03 UTC 2009

Svante Kvarnstrom wrote:
> Hello
> Have you tried -f (for background) and -N for "Do not execute a remote 
> command"? See man 1 ssh for more details.
> Svante

Cheers for you!

It was "-f" without "-N" that produced the error.

I'm guessing I got down the manpage about as far as
"-f" and didn't go any further.  *beats head on desk*

Thanks, Svante!

For the archives:


   sudo ssh -f -N -L localname:24:remotename:52525 me at remotename

When SMTP is listening on "remotename" port 52525.  "sudo" is needed
to open the tunnel on the "localname" side on port 24 (a privileged
port).  You could do this as "root" on the local side, but shouldn't
connect *to* root on the remote computer.

> On Nov 9, 2009, at 7:30 PM, Kevin Kinsey wrote:
>> Greetings!
>> sudo ssh -L thisbox:24:remotebox:52525 me at remotebox
>> I've got Sendmail listening there on 52525, and it works
>> fine; the local clients are told to connect to "thisbox"
>> port 24.  The only issue is that I have to run it from
>> a terminal session.  When I tried to bg the process ("cmdstring &")
>> it doesn't work, exactly.  I've gotten an error message
>> at times*, and at other times I apparently get "thisbox"
>> listening on port 24 but it's not an SMTP daemon that's
>> listening.
>> I have a feeling it's cause I'm in csh, which is notorious
>> for backgrounding issues.  <?>  At any rate, what I'd
>> like to do is have a script set up the connection, or
>> write some daemon that would monitor the connection and
>> fix it if it gets reset.  At any rate, if I could get this
>> SSH process to detach from a terminal, it'd be great.
>> Any suggestions?
>> Kevin Kinsey

More information about the freebsd-questions mailing list