Remote ssh tunnel in background or script?

krad kraduk at googlemail.com
Tue Nov 10 11:18:58 UTC 2009


2009/11/9 Kevin Kinsey <kdk at daleco.biz>

> 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:
>
> SMTP OVER SSH TUNNEL FREEBSD
>
>  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
>>>
>>>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscribe at freebsd.org"
>

if you put it on a port > 1024 instead of 24 you wont need to run it as root
so can drop the sudo bit


More information about the freebsd-questions mailing list