> For the complete documentation index, see [llms.txt](https://d3ndr1t30x.gitbook.io/breaking-things-a-junior-pentesters-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://d3ndr1t30x.gitbook.io/breaking-things-a-junior-pentesters-guide/port-forwarding.md).

# Port forwarding

```bash
ssh -D <local_port> -L<local_port>:<target_ip>:<target_port> <username>@<target_host>
```

* `ssh`: This is the command used to initiate an SSH connection to a remote server.
* `-D <local_port>`: This option sets up dynamic port forwarding. Replace `<local_port>` with the port on your local machine where the SOCKS proxy will listen. This allows you to tunnel your network traffic through the remote server securely.
* `-L<local_port>:<target_ip>:<target_port>`: This option establishes a local port forwarding. Replace `<local_port>` with the port on your local machine that you want to create a forwarding tunnel from. Replace `<target_ip>` with the IP address of the target machine (typically `127.0.0.1` for the remote server itself), and `<target_port>` with the port on the target machine where the service you want to access is running.
* `<username>@<target_host>`: Replace `<username>` with the SSH username for the remote server and `<target_host>` with the IP address or hostname of the target machine you want to connect to. You'll be prompted to enter the user's password to authenticate.
