How does one add a port forward to an openSSH live connection?

Nicholas Leippe nick at leippe.com
Mon Feb 23 08:48:33 MST 2009


On Mon Feb 23 2009 08:32:50 Kenneth Burgener wrote:
> The putty ssh client is an awesome tool.  I also love the fact that
> putty has a Linux, Windows and Mac client, so I can use it from most any
> environment.  One of the features I love is the ability to add a port
> forward from a live connection.  This way I can keep my currently
> forwarded applications running, without having to kill everything then
> reconnect.  Can openSSH add a port forward to a live connection?
>
> I found that I can create the initial port forward with:
>   # local forward
>   $ ssh [host] -L port:host:hostport
>   # remote forward
>   $ ssh [host] -R port:host:hostport
>
> Once I have made the connection, is there a way to signal the ssh
> process to add an additional port forward, similar to Putty?

Yes. You simply issue the escape sequence which drops you to an interactive 
prompt for managing your connections. By default this is ~C (must follow a 
return). See man ssh(1).

> The other feature I found, in Putty, is the "session keep alive"
> feature, which you can also specify time between keep alives.  As far as
> openSSH, I found a "TCPKeepAlive" option, but I am not sure this does
> the same thing as the session keep alive, and I don't see an option to
> specify the time between keep alives.

Yes, this is the keep alive. You may or may not want this feature, however. If 
it is enabled, yes, it will send out keep alive packets so that any router nat 
forwarding tables are refreshed. However, it has the side effect that if it 
fails to receive a keep alive packet it will assume that the connection is 
gone for good and close it on you.

I usually turn it off entirely so that my ssh connections do not notice any 
temporary network outages.

The interval is specified by the server in sshd_config as ClientAliveInterval 
and/or by the client in ssh_config as ServerAliveInterval.
See man sshd_config(5) and ssh_config(5).






More information about the PLUG mailing list