SSH

Create Tunnel and Forward port using SSH.

Local Port Forwarding

Local port forwarding allows you to forward a port on the local (ssh client) machine to a port on the remote (ssh server) machine, which is then forwarded to a port on the destination machine.

ssh -L <ATTACKER_PORT>:localhost:<TARGET_PORT> <USER>@<TARGET_IP>

Remote Port Forwarding

Remote port forwarding is the opposite of local port forwarding. It allows you to forward a port on the remote (ssh server) machine to a port on the local (ssh client) machine, which is then forwarded to a port on the destination machine.

ssh -R <ATTACKER_PORT>:<ATTACKER_IP>:<TARGET_PORT> <USER>@<TARGET_IP>

Dynamic Port Forwarding

Dynamic port forwarding allows you to create a socket on the local (ssh client) machine, which acts as a SOCKS proxy server. When a client connects to this port, the connection is forwarded to the remote (ssh server) machine, which is then forwarded to a dynamic port on the destination machine.

ssh -D <ATTACKER_PORT> <USER>@<TARGET_IP> -fN

Options:

  • f: Requests ssh to background itself after authentication

  • N: Tells ssh not to execute a remote command (empty command)

Last updated