OpenSSH 7.6 release note
New Features
- ssh(1): add support for reverse dynamic forwarding. In this mode,
ssh will act as a SOCKS4/5 proxy and forward connections to
destinations requested by the remote SOCKS client. This mode is
requested using extended syntax for the -R and RemoteForward
options and, because it is implemented solely at the client, does
not require the server be updated to be supported.
review all types ...
local port forwarding
forward (= send) from local (1111
) to a remote (=receive) (2222
)
ssh -L localhost:1111:localhost:2222 remote
use case:
- access an single port/application from a private network
remote port forwarding
forward (= send) from remote (2222
) to a local (= receive) (1111
)
ssh -R localhost:2222:localhost:1111 remote
use case:
- expose a single port/application from a public network to private one
dynamic port forwarding
forward (= send) from local (1111
) to remote (= receive) (all ports + interfaces
)
ssh -D localhost:1111 remote
use case:
- access a network (usually public network) from a private one
- open FireFox, add localhost:1111 as socks5 to access the remote network (
in local network
)
remote dynamic port forwarding (new feature) what you need
forward (= send) from remote to local (= receive) (all ports + interfaces
)
ssh -R localhost:2222 remote
use case:
- expose a network (usually private network) to a public one
- open FireFox, add localhost:2222 as socks5 to access the local network (
in remote network
)
better dynamic port forwarding
ssh -o ConnectTimeout=10 -fNTCD localhost:1234 remote
# -f : fork = go to background
# -N : N not command will be executed at remote
# -T : no TTY
# -C : Compression on
# -D : dynamic
better remote dynamic port forwarding
ssh -o ConnectTimeout=10 -fNTCR localhost:1234 remote
# -f : fork = go to background
# -N : N not command will be executed at remote
# -T : no TTY
# -C : Compression on
# -R : remote
test access to/from dynamic/remote-dynamic port forwarding
curl --socks5-hostname localhost:PORT api.ipify.org
check which applications are connecting to
# on remote/local
lsof -ni :PORT
config file at /home/$USER/.ssh/config
Host remote
HostName a.b.c.d
User username
Port PORT