SSH Tunneling
Background
SSH port forwarding (often referred to as SSH tunneling) is a mechanism in SSH for tunneling application ports from the client to the server, or servers to clients. It can be used for adding encryption to legacy applications, going through firewalls, and some system administrators and IT professionals use it for opening backdoors into the internal network.
Using OpenSSH in Linux we can enable local, remote, or dynamic SSH port forwarding between client and server. more detailed guide can be found at phoenixnap.
- Local Port Forwarding with OpenSSH
ssh -L local_port:destination_server_ip:remote_port ssh_server_hostname
- Remote Port Forwarding with OpenSSH
ssh -R remote_port:localhost:local_port ssh_server_hostname
- Dynamic Port Forwarding with OpenSSH
ssh –D local_port ssh_server_hostname
Enable or disable SSH port forwarding
/etc/ssh/sshd_config has parameter
AllowTcpForwarding no|yes
SSH port forwarding is a powerful feature, and it needs to be carefully administered since leaving port forwarding enabled can expose the organization to security risks and back-doors.
Disabling SSH AllowTcpForwarding is recommended to prevent potential issues
SSH tunnels are widely used in many enterprise environments that employ mainframe systems as their application backends. In those environments the applications themselves may have very limited native support for security. By utilizing tunneling, compliance with SOX, HIPAA, PCI-DSS, and other standards can be achieved without having to modify the applications.[1]