SSH Tunneling


Examples of using OpenSSH for both CLI access, SFTP AND Tunneling.
Avoid exposing vulnerable ports, and use encrypted tunneling instead.

GNU/LINUX Scenario:
Tunnel from localhost:7777 that goes through my SSHD server to remotehost:21 (FTP):
ssh -L 7777:remotehost:21 myuser@remotehost

GNU/LINUX Scenario:
Tunnel from remotehost:7777 that goes to my local webserver:80 (WWW):
ssh -R 7777:localhost:80 myuser@remotehost

WINDOWS Scenario:
Tunnel from localhost:7777 that goes through my SSHD server to remotehost:3389 (RDP):
PuTTY > Connection > SSH > Tunnels > (Add source and destination:port)
From Command Line:
putty.exe -ssh  -l user -pw password

Remote tunneling may require GatewayPorts yes in /etc/sshd_config. Add -fNT as a parameter if you only want to do background port forwarding without opening a shell.