Add a
LocalForward or RemoteForward directive to your client-side ~/.ssh/config file (on Windows: C:\Users\<Username>\.ssh\config).
Open or create
~/.ssh/config and add an entry for your host:
Local forwarding (remote 3080 to local 3080)
If the service runs on the remote machine and you want to open it in your local browser or machine:
Host my-server
HostName example.com
User username
LocalForward 3080 localhost:3080
Remote / reverse forwarding (local 3080 to remote 3080)
If the service runs locally on your laptop and you want the remote server to reach it:
Host my-server
HostName example.com
User username
RemoteForward 3080 localhost:3080
Usage
Once saved, connect using the alias:
ssh my-server
The tunnel binds automatically upon connection.
On Linux and macOS, make sure the config file has strict permissions or SSH will ignore it.
chmod 600 ~/.ssh/config