Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Nov 2009 19:41:01 +0100
From:      adrienfirst <adrien.fontaine@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Remote ssh tunnel in background or script?
Message-ID:  <4AF8623D.9070801@gmail.com>
In-Reply-To: <4AF85FC9.10103@daleco.biz>
References:  <4AF85FC9.10103@daleco.biz>

next in thread | previous in thread | raw e-mail | index | archive | help
Kevin Kinsey a écrit :
> Greetings!
>
> I have a client who recently dropped static IP service in
> favor of a "cheaper" solution, so they're now on a DHCP network
> blocking port 25, etc.
>
> In order to continue to allow them to connect to an outbound
> SMTP box on the LAN, I've done this on their server:
>
> sudo ssh -L thisbox:24:remotebox:52525 me@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
>
> * I'm sorry, but I can't reproduce the error message
> this morning.  IIRC, something to the effect of
> "I can't do nothing, give me a command please?"
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to 
> "freebsd-questions-unsubscribe@freebsd.org"

Try screen ( /usr/ports/sysutils/screen )

screen -S <session_name> <command> to run the session

Ctrl-a Ctrl-z to get out of this session and let it run in background

screen -r <session_name> to return in this session.







Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AF8623D.9070801>