A
cd ..
Network

SSH Tunneling & Port Forwarding

Essential SSH commands for remote access, tunneling, and secure port forwarding.

2025-08-23
ssh, security, networking

SSH into remote server

Basic SSH connection with username and host.

ssh username@remote-host.com

SSH with custom port

ssh -p 2222 username@remote-host.com

Local port forwarding

Forward local port 8080 to remote server's port 80.

ssh -L 8080:localhost:80 username@remote-host.com

Now access localhost:8080 to reach the remote server's port 80.

Remote port forwarding (Reverse tunnel)

Allow remote server to access your local service.

ssh -R 9000:localhost:3000 username@remote-host.com

Dynamic port forwarding (SOCKS proxy)

Create a SOCKS proxy on port 1080.

ssh -D 1080 username@remote-host.com

Configure your browser to use localhost:1080 as SOCKS proxy.

Copy SSH key to server

ssh-copy-id username@remote-host.com

SSH without password prompt (with key)

ssh -i ~/.ssh/id_rsa username@remote-host.com

Was this useful?

Share with your team

Browse More