Linux SSH Tunneling - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux SSH Tunneling Guide
Complete beginner-friendly guide to SSH tunneling on Linux, covering Arch Linux, CachyOS, and other distributions including port forwarding, SOCKS proxy, and secure connections.
Table of Contents
- Understanding SSH Tunneling
- Local Port Forwarding
- Remote Port Forwarding
- Dynamic Port Forwarding
- Troubleshooting
Understanding SSH Tunneling
What is SSH Tunneling?
SSH tunneling creates secure connections through SSH.
Types:
- Local: Forward local port to remote
- Remote: Forward remote port to local
- Dynamic: SOCKS proxy
Uses:
- Bypass firewalls: Access blocked services
- Secure connections: Encrypt traffic
- Remote access: Access local services remotely
Local Port Forwarding
Basic Forwarding
Forward local port:
# Forward local port 8080 to remote 80
ssh -L 8080:localhost:80 user@remote-server
# Access via localhost:8080
Forward to Different Host
Forward to another host:
# Forward to different host
ssh -L 8080:target-server:80 user@remote-server
Remote Port Forwarding
Remote Forwarding
Forward remote port:
# Forward remote port 8080 to local 80
ssh -R 8080:localhost:80 user@remote-server
# Remote can access via localhost:8080
Dynamic Port Forwarding
SOCKS Proxy
Create SOCKS proxy:
# Create SOCKS proxy on port 1080
ssh -D 1080 user@remote-server
# Configure browser to use SOCKS proxy
# localhost:1080
Troubleshooting
Tunnel Not Working
Check connection:
# Test SSH connection
ssh user@remote-server
# Check port forwarding
netstat -tuln | grep 8080
Permission Denied
Check SSH config:
# Check SSH config
cat ~/.ssh/config
# Enable forwarding
AllowTcpForwarding yes
Summary
This guide covered SSH tunneling, port forwarding, and SOCKS proxy for Arch Linux, CachyOS, and other distributions.
Next Steps
- SSH Configuration - SSH setup
- Networking - Network setup
- SSH Documentation: https://www.openssh.com/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.