Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Possible to setup a SSH port forwarding only (!) in background without showing a Terminal window?

2,048 views
Skip to first unread message

Peter Insold

unread,
Jan 21, 2010, 6:25:58 AM1/21/10
to
Whenever I start a SSH port forwarding session with either Windows based Putty or linux based OpenSSH
an additional SSH terminal window is created and shown.

Is there a way to created just a background port forwarding session WITHOUT such a ssh terminal
window in foreground?

Peter

Dag-Erling Smørgrav

unread,
Jan 21, 2010, 6:31:18 AM1/21/10
to
pins...@yahoo.com (Peter Insold) writes:
> Is there a way to created just a background port forwarding session
> WITHOUT such a ssh terminal window in foreground?

man ssh, look for -f, -n and -T.

DES
--
Dag-Erling Smørgrav - d...@des.no

Lusotec

unread,
Jan 21, 2010, 7:31:00 AM1/21/10
to

Yes but If you only want secure port forwarding then stunnel is a simpler
and maybe better choice.

http://www.stunnel.org/

Regards.

C.

unread,
Jan 21, 2010, 7:36:41 AM1/21/10
to

How do you start up the ssh client? I can't imagine why this would
start up a new "SSH terminal window" in Linux (AFAIK there is no such
thing - do you mean in runs in a seperate [x|a|e|k]term?)

If you are manually starting it, then how do you propose shutting it
down if it's not associated with a tty?

C.

Nico Kadel-Garcia

unread,
Jan 21, 2010, 10:35:16 AM1/21/10
to

In many cases, you don't _want_ it shut down. It can be used to
provide a quiet, VPN-like connection to a remote port, active 24x7. In
fact, for such cases, it's useful to use something like "autossh", at
http://www.harding.motd.ca/autossh/. That doesn't help with Putty, but
it's an example of the kind of use involved.

Mind you, it does create it's own fascinating security issues....

Regis

unread,
Jan 21, 2010, 2:11:57 PM1/21/10
to

On windows, you may be interested in putty's cousin plink and it's
-batch option

http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter7.html#7.2.3

Get plink here

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

James Taylor

unread,
Jan 22, 2010, 5:23:08 AM1/22/10
to
Peter Insold wrote:

That's the -N option to ssh. However the use of it is under the ssh
user's control not the ssh server admin's control. To limit what the
user can do at the server end it is necessary to use the sshd config
directives Match and ForceCommand (man sshd_config for details).

Where is the FAQ for this group? This should definitely be in it.

--
James Taylor

Steve Hayes

unread,
Jan 28, 2010, 8:44:28 AM1/28/10
to
Peter Insold wrote:

With linux, you can put the command in a script file and have that run on
system startup, network startup or user login, whichever is most
appropriate.

E.g. I have something similar to the following in ~/.network-autostart and
have that set to run as part of the network startup sequence on my laptop:

#!/bin/sh

/usr/bin/ssh -L1225:localhost:25 -L1443:localhost:143 -CN mydomain.co.uk &

This connects to my server account via port forwarding on the router and
forwards ports 1225 and 1443 on the laptop to ports 25 and 143 on the
server. It is invisible to me as a user: I just set my e-mail client to use
port 1225 on the laptop to send mail and port 1443 to access the IMAP
server.


~/.network-autostop runs when the network disconnects (not unusual with
wireless) and contains

#!/bin/sh

/usr/bin/pkill -u steve ssh

This kills the ssh session and releases the local ports so that forwarding
can be set up again when the network restarts.


I don't know if anything like this can be done with Putty on Windows. If it
can, I'd be interested to hear how to do it as I'd like set up an XP laptop
the same way.


Hope this helps.
--
Steve Hayes, South Wales, UK
----Remove colours from reply address----

0 new messages