The OpenSSH client has a command line option for port forwarding, used like this:
ssh -L localport:server:serverport user@host
which will connect to host
as user
, and at the same time redirecting localport
on the client to serverport
on server
(which can be host
or anything reachable from host
over the network).
Now suppose I have SSHed into host
doing just
ssh user@host
and in the middle of the session I realize I forgot to forward the port. Alas, I am in the middle of something, so I don’t just want to log out and re-establish the SSH connection with the port forwarding.
Is there a way to add port forwarding to a running SSH session?