Skip to content

Creating SSH Tunnels

This comprehensive guide covers creating different types of SSH tunnels using the SSH Tunnel Manager.

Understanding Tunnel Types

Local Port Forwarding

Concept: Forward a local port to a remote destination through an SSH server.

Format: ssh -L local_port:remote_host:remote_port user@ssh_server

Use case: Access services on a remote network that aren't directly accessible.

[Your Computer] → [SSH Server] → [Target Service]
     8080       →      22       →   80 (web server)

Remote Port Forwarding

Concept: Allow remote users to access your local services through the SSH server.

Format: ssh -R remote_port:local_host:local_port user@ssh_server

Use case: Share a local service with remote users.

[Remote Users] → [SSH Server] → [Your Computer]
                    8080       →      3000

Dynamic Port Forwarding (SOCKS Proxy)

Concept: Create a SOCKS proxy that routes traffic through the SSH server.

Format: ssh -D local_port user@ssh_server

Use case: Route all application traffic through the SSH server.

[Your Apps] → [SOCKS Proxy] → [SSH Server] → [Internet]
              localhost:1080      22

Step-by-Step Tunnel Creation

Creating a Local Port Forward

Example: Accessing a Web Interface

  1. Open Configuration Dialog
  2. Click "Add Tunnel" (➕) in the toolbar
  3. Or use menu: File → New Tunnel

  4. Basic Information

    Name: router_admin
    Description: Access router admin interface
    

  5. SSH Connection Settings

    SSH Host: router.example.com
    SSH Port: 22
    SSH User: admin
    SSH Key Path: C:\Users\YourName\.ssh\id_rsa
    

  6. Tunnel Configuration

    Tunnel Type: Local
    Local Port: 8080
    Remote Host: localhost
    Remote Port: 80
    

  7. Save and Test

  8. Click "OK" to save
  9. Select the tunnel and click "Start"
  10. Access via http://localhost:8080

Example: Database Connection

  1. Configuration

    Name: mysql_production
    Description: Production MySQL database
    SSH Host: db-server.company.com
    SSH Port: 22
    SSH User: dbadmin
    Tunnel Type: Local
    Local Port: 3307
    Remote Host: localhost
    Remote Port: 3306
    

  2. Database Client Setup

    Host: localhost
    Port: 3307
    Username: mysql_user
    Password: [mysql_password]
    

Creating a Remote Port Forward

Example: Sharing Local Development Server

  1. Configuration

    Name: dev_server_share
    Description: Share local development server
    SSH Host: public-server.example.com
    SSH Port: 22
    SSH User: developer
    Tunnel Type: Remote
    Local Port: 3000
    Remote Host: localhost
    Remote Port: 8080
    

  2. Result

  3. Your local port 3000 is accessible at public-server.example.com:8080
  4. Others can visit http://public-server.example.com:8080

Creating a Dynamic Port Forward (SOCKS Proxy)

Example: Browsing Through SSH Server

  1. Configuration

    Name: company_proxy
    Description: Browse through company network
    SSH Host: vpn.company.com
    SSH Port: 22
    SSH User: employee
    Tunnel Type: Dynamic
    Local Port: 1080
    

  2. Browser Configuration

  3. Firefox: Settings → Network → Manual proxy

    • SOCKS Host: localhost
    • Port: 1080
    • SOCKS v5: Enabled
  4. Chrome: Start with proxy settings

    chrome --proxy-server="socks5://localhost:1080"
    

Advanced Configuration Options

SSH Key Authentication

Generating SSH Keys

  1. Using SSH Tunnel Manager
  2. Click "SSH Key Setup" in toolbar
  3. Follow the key generation wizard
  4. Automatically deploys keys to servers

  5. Manual Generation

    # Generate ED25519 key (recommended)
    ssh-keygen -t ed25519 -C "your_email@example.com"
    
    # Generate RSA key (compatibility)
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    

Key Deployment

# Copy public key to server
ssh-copy-id user@hostname

# Manual deployment
cat ~/.ssh/id_ed25519.pub | ssh user@hostname "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Auto-Start Configuration

Enable tunnels to start automatically:

  1. Edit tunnel configuration
  2. Check "Auto-start on application launch"
  3. Tunnels will start when the application opens

Multiple Hops (Jump Servers)

For accessing servers through intermediate hosts:

  1. First Tunnel (to jump server)

    Name: jump_server
    SSH Host: jump.company.com
    SSH Port: 22
    SSH User: admin
    Tunnel Type: Local
    Local Port: 2222
    Remote Host: internal-server.local
    Remote Port: 22
    

  2. Second Tunnel (through first tunnel)

    Name: internal_service
    SSH Host: localhost
    SSH Port: 2222
    SSH User: internal_admin
    Tunnel Type: Local
    Local Port: 8080
    Remote Host: localhost
    Remote Port: 80
    

RTSP Video Streaming

IP Camera Access

  1. Tunnel Configuration

    Name: security_camera_01
    Description: Office security camera
    SSH Host: office-router.example.com
    SSH Port: 22
    SSH User: admin
    Tunnel Type: Local
    Local Port: 8554
    Remote Host: 192.168.1.50
    Remote Port: 554
    RTSP URL: rtsp://localhost:8554/live/0
    

  2. Testing the Stream

  3. Start the tunnel
  4. Click "Launch RTSP" in toolbar
  5. Or use external player: vlc rtsp://localhost:8554/live/0

Common RTSP URLs

The SSH Tunnel Manager automatically suggests common RTSP URL patterns:

rtsp://localhost:8554/live/0                    # Generic
rtsp://localhost:8554/stream/0                  # Alternative
rtsp://localhost:8554/cam/realmonitor?channel=1 # Dahua cameras
rtsp://localhost:8554/av0_0                     # Some HIKVISION
rtsp://localhost:8554/axis-media/media.amp      # Axis cameras

Configuration Import/Export

Exporting Configurations

  1. Individual Export
  2. Right-click tunnel in table
  3. Select "Export Configuration"

  4. Bulk Export

  5. Menu: File → Export Configurations
  6. Saves all tunnels to JSON file

Importing Configurations

  1. From File
  2. Menu: File → Import Configurations
  3. Select JSON file
  4. Choose to overwrite or skip duplicates

  5. From Another Installation

  6. Copy configuration files between systems
  7. Windows: %APPDATA%\SSHTunnelManager\
  8. Linux: ~/.config/SSHTunnelManager/

Configuration Format

{
  "version": "1.0",
  "tunnels": {
    "camera_rtsp": {
      "name": "camera_rtsp",
      "ssh_host": "192.168.1.1",
      "ssh_port": 22,
      "ssh_user": "admin",
      "local_port": 8554,
      "remote_host": "192.168.1.50",
      "remote_port": 554,
      "tunnel_type": "local",
      "description": "Security camera access",
      "auto_start": true,
      "ssh_key_path": "/path/to/key",
      "rtsp_url": "rtsp://localhost:8554/live/0"
    }
  }
}

Best Practices

Security

  1. Use SSH Keys: More secure than passwords
  2. Limit Key Access: Set proper file permissions (600)
  3. Regular Key Rotation: Update keys periodically
  4. Host Key Verification: Enable when security is critical

Performance

  1. Connection Limits: Don't create excessive concurrent tunnels
  2. Keep-Alive Settings: Use built-in keep-alive for stability
  3. Local Port Selection: Use ports above 1024 to avoid privilege issues
  4. Monitor Resources: Check system resources with many tunnels

Organization

  1. Descriptive Names: Use clear, descriptive tunnel names
  2. Grouping: Use naming conventions for related tunnels
  3. Documentation: Add meaningful descriptions
  4. Regular Cleanup: Remove unused configurations

Troubleshooting

Common Issues

"Connection Refused"

# Check SSH service
ssh -v user@hostname

# Verify port accessibility
telnet hostname 22

# Check firewall
# Linux: sudo ufw status
# Windows: Windows Defender Firewall settings

"Port Already in Use"

# Find process using port
netstat -tulpn | grep :8080  # Linux
netstat -ano | findstr :8080 # Windows

# Kill process if needed
kill -9 <PID>        # Linux
taskkill /PID <PID>  # Windows

"Permission Denied (publickey)"

# Check key permissions
chmod 600 ~/.ssh/id_rsa

# Test SSH connection
ssh -i ~/.ssh/id_rsa user@hostname

# Check authorized_keys on server
cat ~/.ssh/authorized_keys

"Tunnel Established but Service Unreachable"

# Test from SSH server
ssh user@hostname
telnet remote_host remote_port

# Check tunnel status
netstat -an | grep local_port

Debug Mode

Enable detailed logging:

  1. GUI Application
  2. View → Show Debug Log
  3. Higher verbosity in settings

  4. Command Line

    ssh-tunnel-manager --debug start tunnel_name
    

  5. SSH Verbose Mode

  6. Add -v, -vv, or -vvv to SSH commands for debugging

Next Steps