Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

 ▀▀█▀▀ █ █ █▄ █ █▄ █ █▀▀ █ █▀▀ █▀█ █▀█ █▀▀ █▀▀
█ █ █ █ ▀█ █ ▀█ █▀▀ █ █▀ █ █ █▀█ █ █ █▀▀
█ ▀▀ █ █ █ █ ▀▀▀ ▀▀▀ █ ▀▀▀ █ █ ▀▀▀ ▀▀▀

The Ultimate Single-File SSH Tunnel Manager

License: GPL v3Bash 4.3+Platform: LinuxVersion 1.0.0Zero Dependencies

One script. Every tunnel type. Full TUI. Live dashboard.
SOCKS5 • Local Forward • Remote Forward • Jump Hosts • TLS Obfuscation • Telegram Bot • Kill Switch • DNS Leak Protection


Quick Start

One-line install:

curl -fsSL https://raw.githubusercontent.com/SamNet-dev/tunnelforge/main/tunnelforge.sh -o tunnelforge.sh && sudo bash tunnelforge.sh install

Or clone the repo:

git clone https://github.com/SamNet-dev/tunnelforge.git
cd tunnelforge
sudo bash tunnelforge.sh install

Launch the interactive menu:

tunnelforge menu

Or use CLI directly:

tunnelforge create # Create your first tunnel
tunnelforge start my-tunnel # Start it
tunnelforge dashboard # Watch it live

TunnelForge Main Menu
Interactive TUI — manage tunnels, security, services, and more from a single menu


Why TunnelForge?

Most SSH tunnel tools are either too simple (just a wrapper around ssh -D) or too complex (requiring Docker, Go, Python, or a dozen config files). TunnelForge is different:

TunnelForgeOthers
InstallationSingle bash file, zero dependenciesPython/Go/Node.js + package managers
InterfaceFull TUI menu + CLI + live dashboardCLI-only or web UI requiring a browser
SecurityDNS leak protection, kill switch, audit scoringBasic SSH only
ObfuscationTLS wrapping + PSK to bypass DPI/censorshipNot available
MonitoringReal-time sparkline bandwidth graphsLog files
NotificationsTelegram bot with remote commandsNone
PersistenceAuto-generated systemd servicesManual configuration
EducationBuilt-in Learn menu with diagramsExternal docs
Client SharingOne-click generated scripts (Linux + Windows)Manual setup

TunnelForge is the most complete SSH tunnel manager available as a single file.


Features Overview

Tunnel Management

  • SOCKS5 Dynamic Proxy (-D) — Route all traffic through SSH server
  • Local Port Forwarding (-L) — Access remote services locally
  • Remote/Reverse Forwarding (-R) — Expose local services remotely
  • Jump Host / Multi-Hop (-J) — Chain through bastion servers
  • AutoSSH Integration — Automatic reconnection on drop
  • ControlMaster Multiplexing — Reuse SSH connections
  • Multi-tunnel Support — Run dozens of tunnels simultaneously

Security

  • DNS Leak Protection — Rewrites resolv.conf + locks with chattr
  • Kill Switch — iptables rules block all traffic if tunnel drops (IPv4 + IPv6)
  • 6-Point Security Audit — Scored assessment of your tunnel security posture
  • SSH Key Generation — Create ed25519, RSA, or ECDSA keys
  • SSH Key Deployment — One-command deploy to remote servers
  • Host Fingerprint Verification — Verify server identity before connecting
  • Server Hardening — Automated sshd, firewall, fail2ban, sysctl configuration

Monitoring & Dashboard

  • Live TUI Dashboard — Real-time tunnel status with auto-refresh
  • Sparkline Bandwidth Graphs — ASCII sparklines (▁▂▃▄▅▆▇█) for RX/TX
  • Traffic Counters — Total bytes transferred per tunnel
  • Uptime Tracking — Per-tunnel uptime display
  • Connection Quality — Latency measurement with color-coded indicators
  • Speed Test — Built-in download speed test through tunnel
  • Pagination — Navigate across pages when running many tunnels

Telegram Bot

  • Real-time Alerts — Start, stop, fail, reconnect notifications
  • Remote Commands/tf_status, /tf_list, /tf_ip, /tf_config and more
  • Periodic Reports — Scheduled status reports to your phone
  • Client Sharing — Send connection scripts + PSK via Telegram
  • SOCKS5 Routing — Bot works through your tunnel when Telegram is blocked

TLS Obfuscation (Anti-Censorship)

  • Outbound TLS Wrapping — SSH traffic disguised as HTTPS via stunnel
  • Inbound PSK Protection — SOCKS5 listener secured with Pre-Shared Key
  • Client Script Generator — Auto-generate connect scripts for Linux + Windows
  • One-Click Server Setup — Automated stunnel installation and configuration
  • DPI Bypass — Traffic appears as normal HTTPS on port 443

System Integration

  • Systemd Service Generator — Auto-create hardened unit files
  • Backup & Restore — Full configuration backup with rotation
  • Server Setup Wizard — Harden a fresh server for receiving tunnels
  • Profile Management — Create, edit, delete, import tunnel profiles
  • Log Management — Per-tunnel logs with rotation
  • Clean Uninstall — Complete removal of all files, services, and configs

Built-in Education

  • Learn Menu — 9 interactive lessons on SSH tunneling concepts
  • Scenario Examples — Step-by-step real-world use cases with diagrams
  • ASCII Diagrams — Visual traffic flow for every tunnel type

Tunnel Types Explained

SOCKS5 Dynamic Proxy (-D)

Route all your TCP traffic through a remote SSH server. Your traffic appears to originate from the server's IP address.

┌──────────┐ ┌──────────┐ ┌──────────┐
│ Client │ SSH │ SSH │ Direct │ Target │
│ ├─────────►│ Server ├─────────►│ Website │
│ :1080 │ Encrypted│ │ │ │
└──────────┘ └──────────┘ └──────────┘
▲
Browser
SOCKS5

Use cases: Private browsing, bypass geo-restrictions, hide your IP, route traffic through a different country.

tunnelforge create # Select "SOCKS5 Proxy" → set port 1080
tunnelforge start my-proxy
# Configure browser: SOCKS5 proxy → 127.0.0.1:1080
curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me

Local Port Forwarding (-L)

Access a remote service as if it were running locally. Map a local port to a service behind the SSH server.

┌──────────┐ ┌──────────┐ ┌──────────┐
│ Client │ SSH │ SSH │ Local │ MySQL │
│ ├─────────►│ Server ├─────────►│ :3306 │
│ :3306 │ Encrypted│ │ Network │ │
└──────────┘ └──────────┘ └──────────┘
▲
mysql -h
127.0.0.1

Use cases: Access remote databases, internal web apps, admin panels behind firewalls.

tunnelforge create # Select "Local Forward" → local 3306 → remote db:3306
tunnelforge start db-tunnel
mysql -h 127.0.0.1 -P 3306 -u admin -p

Remote/Reverse Forwarding (-R)

Expose a local service to the outside world through a remote SSH server. Users connect to the server and reach your local machine.

┌──────────┐ ┌──────────┐ ┌──────────┐
│ Local │ SSH │ SSH │ Public │ Users │
│ Dev App │◄────────►│ Server │◄─────────│ on Web │
│ :3000 │ Encrypted│ :9090 │ │ │
└──────────┘ └──────────┘ └──────────┘

Use cases: Webhook development, share local app for testing, NAT traversal, demo to clients.

tunnelforge create # Select "Remote Forward" → remote 9090 ← local 3000
tunnelforge start dev-share
# Others access: http://your-server:9090

Jump Hosts / Multi-Hop (-J)

Reach servers behind multiple layers of firewalls by chaining through intermediate SSH servers.

┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Client │────►│ Bastion │────►│ Jump 2 │────►│ Target │
│ │ SSH │ Server │ SSH │ Server │ SSH │ Server │
└──────────┘ └──────────┘ └──────────┘ └──────────┘

Use cases: Corporate networks, multi-tier architectures, isolated environments, high-security zones.

tunnelforge create # Select "Jump Host" → jumps: admin@bastion:22
tunnelforge start corp-tunnel

Installation

Requirements

RequirementDetails
OSLinux (Ubuntu, Debian, CentOS, Fedora, Arch, Alpine)
Bash4.3 or higher
PrivilegesRoot access for installation
SSHOpenSSH client (pre-installed on most systems)
Optionalautossh (auto-reconnect), stunnel (TLS obfuscation), sshpass (password auth)

Install

# Option 1: Git clone
git clone https://github.com/SamNet-dev/tunnelforge.git
cd tunnelforge
sudo bash tunnelforge.sh install
# Option 2: Direct download
curl -fsSL https://raw.githubusercontent.com/SamNet-dev/tunnelforge/main/tunnelforge.sh -o tunnelforge.sh
sudo bash tunnelforge.sh install

Verify Installation

tunnelforge version
# TunnelForge v1.0.0

Directory Structure

After installation, TunnelForge creates:

/opt/tunnelforge/
├── tunnelforge.sh # Main script
├── config/
│ └── tunnelforge.conf # Global configuration
├── profiles/
│ └── *.conf # Tunnel profiles
├── pids/ # Running tunnel PIDs
├── logs/ # Per-tunnel log files
├── backups/ # Configuration backups
├── data/
│ ├── bandwidth/ # Bandwidth history (sparklines)
│ └── reconnects/ # Reconnect statistics
└── sockets/ # SSH ControlMaster sockets

A symlink is created at /usr/local/bin/tunnelforge for global access.


Quick Examples

Browse Privately via SOCKS5

tunnelforge create
# → Name: private-proxy# → Type: SOCKS5# → Server: user@myserver.com# → Port: 1080
tunnelforge start private-proxy
# Test it
curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me
# Configure Firefox: Settings → Network → Manual Proxy → SOCKS5: 127.0.0.1:1080

Access a Remote Database

tunnelforge create
# → Name: prod-db# → Type: Local Forward# → Server: admin@db-server.internal# → Local port: 3306 → Remote: localhost:3306
tunnelforge start prod-db
mysql -h 127.0.0.1 -P 3306 -u dbuser -p

Share Your Local Dev Server

tunnelforge create
# → Name: demo-share# → Type: Remote Forward# → Server: user@public-vps.com# → Remote port: 8080 ← Local: localhost:3000
tunnelforge start demo-share
# Share with anyone: http://public-vps.com:8080

Chain Through Jump Hosts

tunnelforge create
# → Name: corp-access# → Type: Jump Host# → Jump: admin@bastion.corp.com:22# → Target: user@internal-server:22# → SOCKS5 port: 1080
tunnelforge start corp-access

Bypass Censorship with TLS Obfuscation

# First, set up stunnel on your VPS
tunnelforge obfs-setup my-tunnel
# Now SSH traffic is wrapped in TLS on port 443# DPI sees: normal HTTPS traffic# Reality: SSH tunnel inside TLS
tunnelforge start my-tunnel
# Share with others
tunnelforge client-script my-tunnel # Generates connect scripts
tunnelforge telegram share my-tunnel # Send scripts via Telegram

CLI Reference

Tunnel Commands

CommandDescription
tunnelforge start <name>Start a tunnel
tunnelforge stop <name>Stop a tunnel
tunnelforge restart <name>Restart a tunnel
tunnelforge start-allStart all autostart tunnels
tunnelforge stop-allStop all running tunnels
tunnelforge statusShow all tunnel statuses
tunnelforge dashboardLaunch live TUI dashboard
tunnelforge logs [name]Tail tunnel logs

Profile Commands

CommandDescription
tunnelforge createCreate a new tunnel profile (wizard)
tunnelforge listList all profiles
tunnelforge delete <name>Delete a profile

Security Commands

CommandDescription
tunnelforge auditRun 6-point security audit
tunnelforge key-gen [type]Generate SSH key (ed25519/rsa/ecdsa)
tunnelforge key-deploy <name>Deploy SSH key to server
tunnelforge fingerprint <host> [port]Verify SSH host fingerprint

Telegram Commands

CommandDescription
tunnelforge telegram setupConfigure Telegram bot
tunnelforge telegram testSend test notification
tunnelforge telegram statusShow notification config
tunnelforge telegram send <msg>Send a message
tunnelforge telegram reportSend status report
tunnelforge telegram share [name]Share client scripts via Telegram

Service Commands

CommandDescription
tunnelforge service <name>Generate systemd service
tunnelforge service <name> enableEnable and start service
tunnelforge service <name> disableDisable and stop service
tunnelforge service <name> statusShow service status
tunnelforge service <name> removeRemove service file

System Commands

CommandDescription
tunnelforge menuLaunch interactive TUI
tunnelforge installInstall TunnelForge
tunnelforge server-setupHarden server for tunnels
tunnelforge obfs-setup <name>Set up TLS obfuscation
tunnelforge client-config <name>Show client connection config
tunnelforge client-script <name>Generate client scripts
tunnelforge backupBackup all configs
tunnelforge restore [file]Restore from backup
tunnelforge uninstallRemove everything
tunnelforge versionShow version
tunnelforge helpShow help

Interactive TUI Menu

Launch with tunnelforge menu or just tunnelforge (no arguments):

╔══════════════════════════════════════════════════════════════╗
║ TunnelForge — Main Menu ║
╚══════════════════════════════════════════════════════════════╝
── Tunnels ──
1) Create new tunnel Setup wizard
2) Start a tunnel Launch SSH tunnel
3) Stop a tunnel Terminate tunnel
4) Start All tunnels Launch autostart tunnels
5) Stop All tunnels Terminate all
── Monitoring ──
6) Status Show tunnel statuses
7) Dashboard Live TUI dashboard
── Management ──
8) Profiles Manage tunnel profiles
9) Settings Configure defaults
s) Services Systemd service manager
b) Backup / Restore Manage backups
── Security ──
x) Security Audit Check security posture
k) SSH Key Management Generate & deploy keys
f) Fingerprint Check Verify host fingerprints
── Extras ──
t) Telegram Notification settings
c) Client Configs TLS+PSK connection info
e) Examples Real-world scenarios
l) Learn SSH tunnel concepts
a) About Version & info
u) Uninstall
q) Quit
Select:

Navigate by pressing a single key. No Enter needed. Every menu is keyboard-driven.


Live Dashboard

Launch with tunnelforge dashboard or press 7 in the main menu:

TunnelForge Live Dashboard
Live dashboard with sparkline bandwidth graphs, active connections, reconnect log, and system resources

╔══════════════════════════════════════════════════════════════╗
║ TunnelForge Dashboard v1.0.0 ║
║ Page 1/2 │ 2026-02-07 14:32:15 ║
╚══════════════════════════════════════════════════════════════╝
NAME TYPE STATUS LOCAL UPTIME
────────────────────────────────────────────────────────────
iran-proxy SOCKS5 ● ALIVE 127.0.0.1:1080 2h 8m
RX ▁▂▃▅▇█▇▅▃▂ 412.3 MB TX ▁▁▂▃▅▇▅▃ 82.1 MB
t1-socks5 SOCKS5 ● ALIVE 127.0.0.1:4001 2h 9m
RX ▁▁▁▂▂▃▂▁▁▁ 96.7 KB TX ▁▁▁▁▂▂▁▁ 12.3 KB
db-tunnel LOCAL ■ STOPPED 127.0.0.1:3306 —
dev-share REMOTE ● ALIVE 0.0.0.0:9090 45m
RX ▁▂▂▃▃▂▁▁▁▁ 1.2 MB TX ▁▁▁▂▃▅▃▂ 890 KB
── Active Connections ──
iran-proxy : 3 connections
t1-socks5 : 1 connection
── Recent Log ──
14:32:10 [info] Tunnel 'iran-proxy' reconnected (AutoSSH)
14:30:05 [info] Speed test: 12.4 Mbps via iran-proxy
s=start t=stop r=restart c=create p=speed g=qlty q=quit [</>]

Dashboard Keyboard Controls

KeyAction
sStart a tunnel
tStop a tunnel
rRestart all running tunnels
cCreate a new profile
pRun speed test
gCheck connection quality
[ / ]Previous / next page
qExit dashboard

What It Shows

  • Status — Live running/stopped state per tunnel
  • Uptime — How long each tunnel has been connected
  • Sparkline Graphs — Real-time bandwidth visualization using 8 levels (▁▂▃▄▅▆▇█)
  • Traffic Totals — Cumulative RX/TX bytes per tunnel
  • Active Connections — Number of established TCP connections through each tunnel
  • Recent Logs — Last 4 log entries across all tunnels
  • Pagination — Automatically pages when running 5+ tunnels

Security Features

DNS Leak Protection

Prevents DNS queries from bypassing the tunnel and revealing your real location.

How it works:

  1. Backs up your current /etc/resolv.conf
  2. Rewrites it to use only tunnel-safe DNS servers (default: 8.8.8.8, 8.8.4.4)
  3. Locks the file with chattr +i (immutable) to prevent system overrides
  4. Automatically restores original DNS when tunnel stops
# Enable per-profile in the wizard or editor# Verify with:
tunnelforge audit # Check DNS leak protection status

Kill Switch

If the tunnel drops, all internet traffic is blocked to prevent data leaks.

How it works:

  1. Creates a custom TUNNELFORGE iptables chain
  2. Allows only SSH tunnel traffic + loopback
  3. Blocks everything else (IPv4 + IPv6)
  4. Automatically removes rules when tunnel stops or is manually disabled
# Enable per-profile in the wizard or editor# Verify with:
tunnelforge audit # Check kill switch status

SSH Key Management

# Generate a new key
tunnelforge key-gen ed25519 # Recommended (fast, secure)
tunnelforge key-gen rsa # 4096-bit RSA (broad compatibility)
tunnelforge key-gen ecdsa # ECDSA alternative# Deploy to a tunnel's server
tunnelforge key-deploy my-tunnel

Host Fingerprint Verification

Verify a server's SSH fingerprint before trusting it:

tunnelforge fingerprint myserver.com 22
# Displays SHA256 and MD5 fingerprints# Compare against your server's known fingerprint

6-Point Security Audit

Scores your security posture out of 100 points:

tunnelforge audit
CheckWhat It Verifies
SSH Key PermissionsPrivate keys are 600 or 400
SSH Directory~/.ssh is 700
DNS Leak ProtectionActive DNS protection on running tunnels
Kill Switchiptables chain is active
Tunnel IntegrityPIDs are valid, processes running
System PackagesRequired security tools installed

Server Hardening

Prepare a fresh server to receive SSH tunnels securely:

tunnelforge server-setup

What it configures:

  • SSH daemon — Disable password auth, disable root login, custom port
  • Firewall — UFW/iptables rules for SSH + tunnel ports only
  • Fail2ban — Auto-ban after failed login attempts
  • Kernel — Sysctl hardening (SYN flood protection, ICMP redirects, IP forwarding)

TLS Obfuscation (Anti-Censorship)

In networks with Deep Packet Inspection (DPI), SSH traffic can be detected and blocked. TunnelForge wraps your SSH connection inside a TLS layer, making it look like normal HTTPS traffic.

How It Works

Without TLS Obfuscation:
Client ──── SSH (detectable) ────► VPS ← DPI can block this
With TLS Obfuscation:
Client ──── TLS/443 (looks like HTTPS) ────► VPS ──── SSH ────► Internet
▲
stunnel
unwraps TLS

Setup (Server Side)

# Automatically installs stunnel, generates TLS cert, configures port mapping
tunnelforge obfs-setup my-tunnel

This will:

  1. Install stunnel on the remote server
  2. Generate a self-signed TLS certificate
  3. Map port 443 (TLS) → port 22 (SSH)
  4. Enable as a systemd service
  5. Open the firewall port

Inbound PSK Protection

Protect your local SOCKS5 listener with a Pre-Shared Key. Without the PSK, nobody can connect to your tunnel — even if they find the port.

Client with PSK ──── TLS+PSK ────► Your Machine ──── SOCKS5 ────► Tunnel
Unauthorized ──── TLS ────► Your Machine ──── REJECTED

Share With Others

Generate standalone connect scripts that anyone can use:

# Generate Linux + Windows scripts
tunnelforge client-script my-tunnel
# Share via Telegram (sends scripts + PSK + instructions)
tunnelforge telegram share my-tunnel

Generated scripts include:

  • tunnelforge-connect.sh — Linux bash script (./connect.sh start|stop|status)
  • tunnelforge-connect.ps1 — Windows PowerShell script

Both scripts auto-configure stunnel, create PSK files, and manage the connection lifecycle.

Standalone Windows Client

TunnelForge also ships with windows-client/tunnelforge-client.bat — a ready-to-distribute Windows batch client. Users just double-click it, paste their connection details, and they're connected. No PowerShell required.

Features:

  • Interactive setup — prompts for server, port, and PSK
  • Auto-installs stunnel (via winget, Chocolatey, or manual download link)
  • Saves connection for instant reconnect
  • Commands: tunnelforge-client.bat stop / status
  • Prints browser proxy setup instructions (Firefox + Chrome)
How to distribute:
1. Send windows-client/tunnelforge-client.bat to the user
2. Give them the PSK + server info (from: tunnelforge client-config <profile>)
3. User double-clicks the .bat → enters details → connected

Telegram Bot

Get real-time tunnel notifications on your phone and control tunnels remotely.

Setup

tunnelforge telegram setup
  1. Create a bot — Talk to @BotFather on Telegram, send /newbot
  2. Enter your token — Paste the bot token into TunnelForge
  3. Get your Chat ID — Send /start to your bot, TunnelForge auto-detects your ID
  4. Done — You'll receive a test message confirming setup

Notifications You'll Receive

EventMessage
Tunnel startedProfile name, PID, tunnel type
Tunnel stoppedProfile name
Tunnel failedError details
Tunnel reconnectedAutoSSH auto-recovery
Security alertDNS leak or kill switch event
Status reportAll tunnels overview (periodic)

Bot Commands

Send these commands to your bot from Telegram:

CommandResponse
/tf_statusAll tunnel statuses
/tf_listList all profiles
/tf_ipServer's public IP
/tf_configClient connection configs (PSK info)
/tf_uptimeServer uptime
/tf_reportFull status report
/tf_helpAvailable commands

Configuration

tunnelforge telegram status # View current config
tunnelforge telegram test# Send test message
tunnelforge telegram send "Hello from TunnelForge!"

Enable periodic reports (e.g., every hour):

Settings → Telegram → Toggle Status Reports → Set Interval

Systemd Services

Make your tunnels survive reboots with auto-generated systemd service files.

Usage

# Generate a service file
tunnelforge service my-tunnel
# Enable and start (survives reboot)
tunnelforge service my-tunnel enable# Check status
tunnelforge service my-tunnel status
# Disable
tunnelforge service my-tunnel disable
# Remove service file
tunnelforge service my-tunnel remove

Generated Service Features

The auto-generated unit file includes security hardening:

  • ProtectSystem=strict — Read-only filesystem
  • ProtectHome=tmpfs — Isolated home directory
  • PrivateTmp=true — Private temp directory
  • CAP_NET_ADMIN — Only if kill switch is enabled
  • CAP_LINUX_IMMUTABLE — Only if DNS leak protection is enabled
  • Automatic restart policies
  • Proper start/stop timeouts

Backup & Restore

Backup

tunnelforge backup

Creates a timestamped .tar.gz archive containing:

  • All tunnel profiles
  • Global configuration
  • SSH keys (if stored in TunnelForge directory)
  • Systemd service files

Backups are stored in /opt/tunnelforge/backups/ with automatic rotation.

Restore

# Restore from latest backup
tunnelforge restore
# Restore from specific file
tunnelforge restore /path/to/backup.tar.gz

Configuration Reference

Global Config (/opt/tunnelforge/config/tunnelforge.conf)

SettingDefaultDescription
SSH_DEFAULT_USERrootDefault SSH username
SSH_DEFAULT_PORT22Default SSH port
SSH_DEFAULT_KEYDefault identity key path
SSH_CONNECT_TIMEOUT10Connection timeout (seconds)
AUTOSSH_ENABLEDtrueEnable AutoSSH by default
AUTOSSH_POLL30AutoSSH poll interval (seconds)
CONTROLMASTER_ENABLEDfalseSSH connection multiplexing
LOG_LEVELinfoLogging verbosity (debug/info/warn/error)
DASHBOARD_REFRESH3Dashboard refresh rate (seconds)
DNS_LEAK_PROTECTIONfalseDNS leak protection default
KILL_SWITCHfalseKill switch default
TELEGRAM_ENABLEDfalseEnable Telegram notifications
TELEGRAM_BOT_TOKENBot token from @BotFather
TELEGRAM_CHAT_IDYour Telegram chat ID
TELEGRAM_ALERTStrueSend tunnel event alerts
TELEGRAM_PERIODIC_STATUSfalseSend periodic reports
TELEGRAM_STATUS_INTERVAL3600Report interval (seconds)

Profile Fields

Each tunnel profile (/opt/tunnelforge/profiles/<name>.conf) contains:

FieldDescription
TUNNEL_TYPEsocks5, local, remote, or jump
SSH_HOSTServer hostname or IP
SSH_PORTSSH port (default 22)
SSH_USERSSH username
SSH_PASSWORDSSH password (optional)
IDENTITY_KEYPath to SSH private key
LOCAL_BIND_ADDRLocal bind address
LOCAL_PORTLocal port number
REMOTE_HOSTRemote target host
REMOTE_PORTRemote target port
JUMP_HOSTSComma-separated jump hosts
SSH_OPTIONSExtra SSH flags
AUTOSSH_ENABLEDAutoSSH toggle
DNS_LEAK_PROTECTIONDNS protection toggle
KILL_SWITCHKill switch toggle
AUTOSTARTStart on boot
OBFS_MODEnone or stunnel
OBFS_PORTTLS obfuscation port
OBFS_LOCAL_PORTInbound TLS+PSK port
OBFS_PSKPre-Shared Key (hex)
DESCRIPTIONProfile description

Real-World Scenarios

Each scenario below is expandable and shows the exact wizard steps you'll follow. Both SSH-only and TLS-encrypted variants are covered where applicable.

Scenario 1: Private Browsing via SOCKS5

Goal: Route all your browser traffic through a VPS so websites see the VPS IP instead of yours.

Your PC :1080 ──── SSH (Encrypted) ────► VPS ──── Direct ────► Internet
▲
Websites see
the VPS IP

What you need: A VPS or remote server with SSH access.

Wizard Steps (SSH-only)

tunnelforge create
StepPromptWhat to enter
1Profile nameprivate-proxy
2Tunnel type1 — SOCKS5 Proxy
3SSH hostYour VPS IP (e.g. 45.33.32.10)
4SSH port22 (default)
5SSH userroot (or your username)
6SSH passwordYour password (or Enter to skip for key auth)
7Identity key~/.ssh/id_ed25519 (or Enter to skip)
8Auth testAutomatic — verifies connection
9aBind address127.0.0.1 (local only) or 0.0.0.0 (share with LAN)
9bSOCKS5 port1080
10Connection mode1 — Regular SSH
11Inbound protection1 — None
12AutoSSHy (recommended)
13Save & starty then y

Wizard Steps (TLS-encrypted — for censored networks)

Same as above, but at step 10:

StepPromptWhat to enter
10Connection mode2 — TLS Encrypted
10aTLS port443 (looks like HTTPS)
10bSetup stunnel now?y (auto-installs on server)
11Inbound protection1 — None (you're the only user)

After Starting

Firefox:

  1. Settings → search "proxy" → Manual proxy configuration
  2. SOCKS Host: 127.0.0.1 — Port: 1080
  3. Select "SOCKS v5"
  4. Check "Proxy DNS when using SOCKS v5"

Chrome:

google-chrome --proxy-server="socks5://127.0.0.1:1080"

Test it works:

curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me
# Should show your VPS IP, not your real IP

Scenario 2: Access a Remote Database

Goal: Access MySQL/PostgreSQL running on your VPS as if it were on your local machine.

Your PC :3306 ──── SSH (Encrypted) ────► VPS ──── Local ────► MySQL :3306

What you need: A VPS with a database running (e.g. MySQL on port 3306).

Wizard Steps

tunnelforge create
StepPromptWhat to enter
1Profile nameprod-db
2Tunnel type2 — Local Port Forward
3SSH hostYour VPS IP (e.g. 45.33.32.10)
4SSH port22
5SSH userroot
6SSH passwordYour password (or Enter to skip)
7Identity keyEnter to skip (or path to key)
8Auth testAutomatic
9aBind address127.0.0.1
9bLocal port3306 (port on YOUR machine)
9cRemote host127.0.0.1 (means "on the VPS itself")
9dRemote port3306 (MySQL port on VPS)
10Connection mode1 — Regular SSH
11Inbound protection1 — None
12AutoSSHy
13Save & starty then y

After Starting

# MySQL
mysql -h 127.0.0.1 -P 3306 -u dbuser -p
# PostgreSQL (change ports to 5432)
psql -h 127.0.0.1 -p 5432 -U postgres
# Redis (change ports to 6379)
redis-cli -h 127.0.0.1 -p 6379
# Web admin panel (change ports to 8080)# Open browser: http://127.0.0.1:8080

Common Variations

ServiceLocal PortRemote Port
MySQL33063306
PostgreSQL54325432
Redis63796379
Web panel80808080
MongoDB2701727017

Tip: Set Remote host to another IP on the VPS network (e.g. 10.0.0.5) to reach a database on a private subnet that only the VPS can access.

Scenario 3: Share Your Local Dev Server

Goal: You have a website running locally (e.g. on port 3000) and want others on the internet to access it through your VPS.

Local App :3000 ◄──── SSH (Encrypted) ────► VPS :9090 ◄──── Users on Web

What you need: A local service running + a VPS with a public IP.

Wizard Steps

tunnelforge create
StepPromptWhat to enter
1Profile namedev-share
2Tunnel type3 — Remote/Reverse Forward
3SSH hostYour VPS IP (e.g. 45.33.32.10)
4SSH port22
5SSH userroot
6SSH passwordYour password
7Identity keyEnter to skip
8Auth testAutomatic
9aRemote bind0.0.0.0 (public access — requires GatewayPorts yes in sshd)
9bRemote port9090 (port on VPS others connect to)
9cLocal host127.0.0.1 (this machine)
9dLocal port3000 (your running app)
10Connection mode1 — Regular SSH
11Inbound protection1 — None
12AutoSSHy
13Save & starty then y

Important: Enable GatewayPorts

If using 0.0.0.0 bind (public access), your VPS sshd needs:

# On VPS: edit /etc/ssh/sshd_config
GatewayPorts yes
# Then restart sshd
sudo systemctl restart sshd

If using 127.0.0.1 bind, the port is only accessible from the VPS itself.

After Starting

# Make sure your local service is running first:
python3 -m http.server 3000 # or: npm start, etc.# Test from VPS (SSH into it):
curl http://localhost:9090
# Test from anywhere (if bind is 0.0.0.0):
curl http://45.33.32.10:9090
# Share with clients:# "Visit http://45.33.32.10:9090 to see the demo"

Common Use Cases

Use CaseLocal PortWhat's Exposed
Node.js dev server3000Web app
React/Vue dev server5173Frontend
Webhook receiver8080API endpoint
SSH to home PC22SSH access

Scenario 4: Multi-Hop Through Bastion / Jump Hosts

Goal: Reach a server that is NOT directly accessible from the internet. You hop through one or more intermediate servers.

Your PC ── SSH ──► Bastion (public) ── SSH ──► Target (hidden)

What you need: SSH access to the jump/bastion server + the target server.

Wizard Steps (SOCKS5 at target)

tunnelforge create
StepPromptWhat to enter
1Profile namecorp-access
2Tunnel type4 — Jump Host
3SSH hostTarget IP (e.g. 10.0.50.100)
4SSH port22
5SSH useradmin (user on target)
6SSH passwordPassword for target
7Identity keyKey for target
8Auth testMay fail (target not reachable directly) — continue anyway
9aJump hostsroot@bastion.example.com:22
9bTunnel type at destination1 — SOCKS5 Proxy
9cBind address127.0.0.1
9dSOCKS5 port1080
10Connection mode1 — Regular SSH
11Inbound protection1 — None
12AutoSSHy
13Save & starty then y

Important: Step 3-7 are for the TARGET server. Jump host credentials go in step 9a using the format user@host:port.

Wizard Steps (Local Forward at target)

Same as above, but at step 9:

StepPromptWhat to enter
9aJump hostsroot@bastion.example.com:22
9bTunnel type at destination2 — Local Port Forward
9cBind address127.0.0.1
9dLocal port8080
9eRemote host127.0.0.1 (on the target)
9fRemote port80 (web server on target)

Multiple Jump Hosts

Chain through several servers by comma-separating them:

Jump hosts: user1@hop1.com:22,user2@hop2.com:22
Your PC ──► hop1.com ──► hop2.com ──► Target

After Starting

# SOCKS5 mode — set browser proxy:# 127.0.0.1:1080# Local Forward mode — open in browser:# http://127.0.0.1:8080 → shows target's web server

Scenario 5: Bypass DPI Censorship (Single VPS)

Goal: Your ISP uses Deep Packet Inspection (DPI) to detect and block SSH traffic. Wrap SSH in TLS so it looks like normal HTTPS.

Without TLS: Your PC ──── SSH (blocked by DPI) ────► VPS
With TLS: Your PC ──── TLS/443 (looks like HTTPS) ────► VPS ──► Internet

What you need: 1 VPS outside the censored network.

Wizard Steps

tunnelforge create
StepPromptWhat to enter
1Profile namebypass-proxy
2Tunnel type1 — SOCKS5 Proxy
3SSH hostYour VPS IP (e.g. 45.33.32.10)
4SSH port22
5SSH userroot
6SSH passwordYour password
7Identity keyEnter to skip
8Auth testAutomatic
9aBind address127.0.0.1
9bSOCKS5 port1080
10Connection mode2 — TLS Encrypted
10aTLS port443 (mimics HTTPS — most effective)
10bSetup stunnel on server?y (auto-installs stunnel on VPS)
11Inbound protection1 — None (you're connecting directly)
12AutoSSHy
13Save & starty then y

What Happens Behind the Scenes

  1. TunnelForge installs stunnel on your VPS
  2. Stunnel listens on port 443 (TLS) and forwards to SSH port 22
  3. Your local SSH client connects through stunnel via openssl s_client
  4. DPI only sees a TLS handshake on port 443 — indistinguishable from HTTPS

After Starting

# Set browser SOCKS5 proxy: 127.0.0.1:1080
curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me
# Shows VPS IP — you're browsing through TLS-wrapped SSH

What DPI Sees

Your PC ──── HTTPS traffic on port 443 ────► VPS IP
Verdict: Normal website browsing. Allowed.

Scenario 6: Double-Hop TLS Chain (Two VPS)

Goal: Run a shared proxy for multiple users. VPS-A is the entry point (relay). VPS-B is the exit point. Both legs are TLS-encrypted. Users connect with a PSK.

Users ── TLS+PSK:1443 ──► VPS-A (relay) ── TLS:443 ──► VPS-B (exit) ──► Internet
stunnel+PSK stunnel
SOCKS5:1080 SSH:22

What you need: 2 VPS servers. VPS-A = relay (can be in censored country). VPS-B = exit (outside).

Wizard Steps (run on VPS-A)

Install TunnelForge on VPS-A, then:

tunnelforge create
StepPromptWhat to enter
1Profile namedouble-hop
2Tunnel type1 — SOCKS5 Proxy
3SSH hostVPS-B IP (e.g. 203.0.113.50)
4SSH port22
5SSH userroot
6SSH passwordVPS-B password
7Identity keyEnter to skip
8Auth testAutomatic
9aBind address127.0.0.1 (stunnel handles external)
9bSOCKS5 port1080
10Connection mode2 — TLS Encrypted
10aTLS port443
10bSetup stunnel on VPS-B?y
11Inbound protection2 — TLS + PSK
11aInbound TLS port1443 (users connect here)
11bPSKAuto-generated (saved in profile)
12AutoSSHy
13Save & starty then y

Generate Client Scripts for Users

# On VPS-A after tunnel is running:
tunnelforge client-script double-hop
# Creates:# tunnelforge-connect.sh (Linux)# tunnelforge-connect.ps1 (Windows)# Or send via Telegram:
tunnelforge telegram share double-hop

What Users Do

Linux:

chmod +x tunnelforge-connect.sh
./tunnelforge-connect.sh # Connect
./tunnelforge-connect.sh stop # Disconnect
./tunnelforge-connect.sh status # Check# Set browser proxy: 127.0.0.1:1080

Windows PowerShell:

powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1 # Connect
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1 stop # Disconnect
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1 status # Check# Set browser proxy: 127.0.0.1:1080

Windows Batch (standalone client):

tunnelforge-client.bat # Double-click, enter server/port/PSK
tunnelforge-client.bat stop # Disconnect
tunnelforge-client.bat status # Check
# Set browser proxy: 127.0.0.1:1080

What DPI Sees

User PC ──── HTTPS:1443 ──► VPS-A IP (normal TLS)
VPS-A ──── HTTPS:443 ──► VPS-B IP (normal TLS)
No SSH protocol visible anywhere in the chain.

Scenario 7: Share Your Tunnel With Others

Goal: You have a working tunnel with TLS+PSK protection and want to give others access. TunnelForge generates a standalone script they just run.

What you need: A running tunnel with Inbound TLS+PSK enabled (see Scenario 5 or 6).

Step 1 — Generate Client Scripts

tunnelforge client-script my-tunnel

This creates two files:

  • tunnelforge-connect.sh — for Linux/Mac
  • tunnelforge-connect.ps1 — for Windows PowerShell

Each script contains your server address, port, and PSK — everything needed to connect.

Or use the standalone Windows client: Send users windows-client/tunnelforge-client.bat from the repo — they double-click it, enter connection details, and they're connected. No scripts to generate.

Step 2 — Send to Users

Share via:

  • Telegram: tunnelforge telegram share my-tunnel
  • WhatsApp, email, USB drive, or any file transfer method
  • For Windows users: also send windows-client/tunnelforge-client.bat (or just send the .bat alone with PSK info)

Step 3 — User Runs the Script

Linux:

chmod +x tunnelforge-connect.sh
./tunnelforge-connect.sh # Connect (auto-installs stunnel if needed)
./tunnelforge-connect.sh stop # Disconnect
./tunnelforge-connect.sh status # Check connection

Windows (PowerShell — generated script):

powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1 stop
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1 status

Windows (Batch — standalone client):

tunnelforge-client.bat # Double-click or run — enter server/port/PSK when prompted
tunnelforge-client.bat stop # Disconnect
tunnelforge-client.bat status # Check connection

All clients automatically:

  1. Install stunnel if not present (winget/Chocolatey/apt)
  2. Write config files locally
  3. Start stunnel and create a local SOCKS5 proxy
  4. Print browser setup instructions (Firefox + Chrome)

After Connecting

Browser proxy: 127.0.0.1:1080
All traffic routes through the tunnel.

View Connection Info Without Scripts

# Show PSK + server + port info (for manual setup):
tunnelforge client-config my-tunnel

Revoking Access

To revoke a user's access:

  1. Edit the profile and regenerate the PSK
  2. Regenerate client scripts: tunnelforge client-script my-tunnel
  3. Restart the tunnel: tunnelforge restart my-tunnel
  4. Old scripts will no longer work — distribute the new ones to authorized users only

Learn Menu (Built-in Education)

TunnelForge includes an interactive learning system accessible from the main menu (l key) or CLI. Each topic includes explanations, ASCII diagrams, and practical examples.

#TopicDescription
1What is an SSH Tunnel?Encrypted channel fundamentals
2SOCKS5 Dynamic ProxyRoute all traffic through -D flag
3Local Port ForwardingAccess remote services via -L flag
4Remote/Reverse ForwardingExpose local services via -R flag
5Jump Hosts & Multi-hopChain through bastions via -J flag
6ControlMaster MultiplexingReuse SSH connections for speed
7AutoSSH & ReconnectionAutomatic tunnel recovery
8What is TLS Obfuscation?Wrap SSH in TLS to bypass DPI
9PSK AuthenticationPre-Shared Key for tunnel security

License & Author

TunnelForge is licensed under the GNU General Public License v3.0.

Copyright (C) 2026 SamNet Technologies, LLC

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

 ▀▀█▀▀ █ █ █▄ █ █▄ █ █▀▀ █ █▀▀ █▀█ █▀█ █▀▀ █▀▀
█ █ █ █ ▀█ █ ▀█ █▀▀ █ █▀ █ █ █▀█ █ █ █▀▀
█ ▀▀ █ █ █ █ ▀▀▀ ▀▀▀ █ ▀▀▀ █ █ ▀▀▀ ▀▀▀

کامل‌ترین مدیر تانل SSH در یک فایل

License: GPL v3Bash 4.3+Platform: LinuxVersion 1.0.0بدون وابستگی

یک اسکریپت. همه انواع تانل. رابط کاربری کامل. داشبورد زنده..
SOCKS5 • Local Forward • Remote Forward • Jump Host • رمزنگاری TLS • ربات تلگرام • Kill Switch • محافظت DNS


شروع سریع

نصب با یک دستور:

curl -fsSL https://raw.githubusercontent.com/SamNet-dev/tunnelforge/main/tunnelforge.sh -o tunnelforge.sh && sudo bash tunnelforge.sh install

یا کلون ریپو:

git clone https://github.com/SamNet-dev/tunnelforge.git
cd tunnelforge
sudo bash tunnelforge.sh install

اجرای منوی تعاملی:

tunnelforge menu

یا استفاده مستقیم از CLI:

tunnelforge create # ساخت اولین تانل
tunnelforge start my-tunnel # شروع تانل
tunnelforge dashboard # داشبورد زنده

منوی اصلی TunnelForge
رابط کاربری تعاملی — مدیریت تانل‌ها، امنیت، سرویس‌ها و بیشتر از یک منو


چرا TunnelForge؟

بیشتر ابزارهای مدیریت تانل SSH یا خیلی ساده هستند (فقط یک wrapper روی ssh -D) یا خیلی پیچیده (نیاز به Docker، Go، Python یا دهها فایل تنظیمات). TunnelForge متفاوت است:

TunnelForgeسایر ابزارها
نصبیک فایل bash، بدون وابستگیPython/Go/Node.js + package manager
رابط کاربریمنوی TUI کامل + CLI + داشبورد زندهفقط CLI یا Web UI
امنیتمحافظت DNS، کیل سوییچ، امتیازدهی امنیتیفقط SSH ساده
رمزنگاریپوشش TLS + PSK برای عبور از DPIندارد
مانیتورینگنمودار پهنای باند لحظه‌ایفایل‌های لاگ
اطلاع‌رسانیربات تلگرام با دستورات ریموتندارد
پایداریسرویس systemd خودکارتنظیم دستی
آموزشمنوی یادگیری داخلی با دیاگراممستندات خارجی
اشتراک‌گذاریتولید اسکریپت اتصال (Linux + Windows)تنظیم دستی

TunnelForge کامل‌ترین مدیر تانل SSH موجود در یک فایل است.


مروری بر امکانات

مدیریت تانل

  • پراکسی SOCKS5 داینامیک (-D) — مسیریابی تمام ترافیک از طریق سرور SSH
  • Port Forwarding محلی (-L) — دسترسی محلی به سرویس‌های ریموت
  • Port Forwarding معکوس (-R) — نمایش سرویس‌های محلی به بیرون
  • Jump Host / چند مرحله‌ای (-J) — عبور از سرورهای واسط
  • AutoSSH — اتصال مجدد خودکار
  • ControlMaster — استفاده مجدد از اتصالات SSH
  • چند تانل همزمان — اجرای دهها تانل به صورت موازی

امنیت

  • محافظت از نشت DNS — بازنویسی resolv.conf + قفل با chattr
  • کیل سوییچ — مسدود کردن تمام ترافیک در صورت قطع تانل (IPv4 + IPv6)
  • ممیزی امنیتی ۶ نقطه‌ای — ارزیابی امتیازی وضعیت امنیتی
  • تولید کلید SSH — ساخت کلیدهای ed25519، RSA یا ECDSA
  • استقرار کلید SSH — ارسال کلید به سرور با یک دستور
  • تأیید اثرانگشت سرور — بررسی هویت سرور قبل از اتصال
  • سخت‌سازی سرور — تنظیم خودکار sshd، فایروال، fail2ban و sysctl

مانیتورینگ و داشبورد

  • داشبورد TUI زنده — وضعیت لحظه‌ای تانل‌ها با رفرش خودکار
  • نمودار پهنای باند Sparkline — نمودارهای ASCII (▁▂▃▄▅▆▇█) برای RX/TX
  • شمارنده ترافیک — کل بایت‌های ارسال و دریافت هر تانل
  • ردیابی Uptime — نمایش زمان اتصال هر تانل
  • کیفیت اتصال — اندازه‌گیری تأخیر با نشانگر رنگی
  • تست سرعت — تست سرعت دانلود داخلی از طریق تانل
  • صفحه‌بندی — ناوبری در صفحات مختلف برای تانل‌های زیاد

داشبورد زنده TunnelForge
داشبورد زنده با نمودار پهنای باند، اتصالات فعال، لاگ اتصال مجدد و منابع سیستم

ربات تلگرام

  • اعلان‌های لحظه‌ای — شروع، توقف، خطا، اتصال مجدد
  • دستورات ریموت/tf_status، /tf_list، /tf_ip، /tf_config و بیشتر
  • گزارش‌های دوره‌ای — ارسال زمان‌بندی شده وضعیت به گوشی
  • اشتراک‌گذاری — ارسال اسکریپت اتصال + PSK از طریق تلگرام
  • مسیریابی SOCKS5 — ربات از طریق تانل کار می‌کند وقتی تلگرام مسدود است

رمزنگاری TLS (ضد سانسور)

  • پوشش TLS خروجی — ترافیک SSH به شکل HTTPS از طریق stunnel
  • محافظت PSK ورودی — لیسنر SOCKS5 با کلید پیش‌اشتراکی
  • تولید اسکریپت کلاینت — ساخت خودکار اسکریپت اتصال برای Linux + Windows
  • راه‌اندازی خودکار سرور — نصب و پیکربندی stunnel با یک دستور
  • عبور از DPI — ترافیک مانند HTTPS معمولی روی پورت 443

یکپارچگی سیستم

  • تولیدکننده سرویس Systemd — ساخت خودکار فایل‌های unit امن
  • پشتیبان‌گیری و بازیابی — بکاپ کامل تنظیمات با چرخش
  • ویزارد سخت‌سازی سرور — آماده‌سازی سرور تازه برای دریافت تانل
  • مدیریت پروفایل — ساخت، ویرایش، حذف، وارد کردن پروفایل
  • مدیریت لاگ — لاگ مجزا برای هر تانل با چرخش
  • حذف کامل — پاکسازی تمام فایل‌ها، سرویس‌ها و تنظیمات

آموزش داخلی

  • منوی یادگیری — ۹ درس تعاملی درباره مفاهیم تانل SSH
  • سناریوهای واقعی — راهنمای گام به گام با دیاگرام
  • دیاگرام‌های ASCII — نمایش بصری جریان ترافیک

انواع تانل

پراکسی SOCKS5 داینامیک (-D)

تمام ترافیک TCP خود را از طریق سرور SSH مسیریابی کنید. ترافیک شما از IP سرور ارسال می‌شود.

Client :1080 ──── SSH (Encrypted) ────► Server ──── Direct ────► Internet

کاربردها: مرور خصوصی، عبور از محدودیت‌های جغرافیایی، مخفی کردن IP، مسیریابی ترافیک.

tunnelforge create # انتخاب "SOCKS5 Proxy" → پورت 1080
tunnelforge start my-proxy
curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me

Port Forwarding محلی (-L)

به یک سرویس ریموت دسترسی پیدا کنید انگار روی سیستم خودتان اجرا می‌شود.

Client :3306 ──── SSH (Encrypted) ────► Server ──── Local ────► MySQL :3306

کاربردها: دسترسی به دیتابیس ریموت، وب اپلیکیشن‌های داخلی، پنل‌های مدیریتی پشت فایروال.

tunnelforge create # انتخاب "Local Forward" → محلی 3306 → ریموت db:3306
tunnelforge start db-tunnel
mysql -h 127.0.0.1 -P 3306 -u admin -p

Port Forwarding معکوس (-R)

یک سرویس محلی را از طریق سرور SSH در دسترس دنیای بیرون قرار دهید.

Local App :3000 ◄──── SSH (Encrypted) ────► Server :9090 ◄──── Users

کاربردها: توسعه webhook، اشتراک‌گذاری اپ برای تست، عبور از NAT، دمو به مشتری.

tunnelforge create # انتخاب "Remote Forward" → ریموت 9090 ← محلی 3000
tunnelforge start dev-share

Jump Host / چند مرحله‌ای (-J)

به سرورهایی که پشت چندین لایه فایروال هستند از طریق سرورهای واسط دسترسی پیدا کنید.

Client ── SSH ──► Jump 1 ── SSH ──► Jump 2 ── SSH ──► Target

کاربردها: شبکه‌های سازمانی، معماری چند لایه، محیط‌های ایزوله، مناطق امنیتی.


نصب

پیش‌نیازها

پیش‌نیازجزئیات
سیستم عاملLinux (Ubuntu، Debian، CentOS، Fedora، Arch، Alpine)
Bashنسخه ۴.۳ یا بالاتر
دسترسیدسترسی root برای نصب
SSHکلاینت OpenSSH (در اکثر سیستم‌ها نصب است)
اختیاریautossh (اتصال مجدد خودکار)، stunnel (رمزنگاری TLS)، sshpass (احراز هویت با رمز)

نصب

# روش ۱: کلون از Git
git clone https://github.com/SamNet-dev/tunnelforge.git
cd tunnelforge
sudo bash tunnelforge.sh install
# روش ۲: دانلود مستقیم
curl -fsSL https://raw.githubusercontent.com/SamNet-dev/tunnelforge/main/tunnelforge.sh -o tunnelforge.sh
sudo bash tunnelforge.sh install

تأیید نصب

tunnelforge version
# TunnelForge v1.0.0

ساختار دایرکتوری

/opt/tunnelforge/
├── tunnelforge.sh # اسکریپت اصلی
├── config/
│ └── tunnelforge.conf # تنظیمات کلی
├── profiles/
│ └── *.conf # پروفایل تانل‌ها
├── pids/ # فایل‌های PID تانل‌های فعال
├── logs/ # لاگ هر تانل
├── backups/ # فایل‌های پشتیبان
├── data/
│ ├── bandwidth/ # تاریخچه پهنای باند
│ └── reconnects/ # آمار اتصال مجدد
└── sockets/ # سوکت‌های ControlMaster

مثال‌های سریع

مرور خصوصی با SOCKS5

tunnelforge create
# → نام: private-proxy# → نوع: SOCKS5# → سرور: user@myserver.com# → پورت: 1080
tunnelforge start private-proxy
curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me
# تنظیم فایرفاکس: Settings → Network → Manual Proxy → SOCKS5: 127.0.0.1:1080

دسترسی به دیتابیس ریموت

tunnelforge create
# → نام: prod-db# → نوع: Local Forward# → سرور: admin@db-server.internal# → پورت محلی: 3306 → ریموت: localhost:3306
tunnelforge start prod-db
mysql -h 127.0.0.1 -P 3306 -u dbuser -p

اشتراک‌گذاری سرور توسعه

tunnelforge create
# → نام: demo-share# → نوع: Remote Forward# → سرور: user@public-vps.com# → پورت ریموت: 8080 ← محلی: localhost:3000
tunnelforge start demo-share
# لینک اشتراک: http://public-vps.com:8080

عبور از سانسور با رمزنگاری TLS

# ۱. راه‌اندازی stunnel روی VPS
tunnelforge obfs-setup my-tunnel
# ۲. شروع تانل — SSH حالا در TLS پورت 443 پوشش داده شده
tunnelforge start my-tunnel
# DPI می‌بیند: ترافیک HTTPS عادی# واقعیت: تانل SSH داخل TLS# ۳. اشتراک با دیگران
tunnelforge client-script my-tunnel # تولید اسکریپت اتصال
tunnelforge telegram share my-tunnel # ارسال از طریق تلگرام

مرجع دستورات CLI

دستورات تانل

دستورتوضیح
tunnelforge start <name>شروع تانل
tunnelforge stop <name>توقف تانل
tunnelforge restart <name>راه‌اندازی مجدد
tunnelforge start-allشروع همه تانل‌های خودکار
tunnelforge stop-allتوقف همه تانل‌ها
tunnelforge statusنمایش وضعیت
tunnelforge dashboardداشبورد زنده
tunnelforge logs [name]مشاهده لاگ

دستورات پروفایل

دستورتوضیح
tunnelforge createساخت پروفایل جدید (ویزارد)
tunnelforge listلیست پروفایل‌ها
tunnelforge delete <name>حذف پروفایل

دستورات امنیتی

دستورتوضیح
tunnelforge auditممیزی امنیتی ۶ نقطه‌ای
tunnelforge key-gen [type]تولید کلید SSH
tunnelforge key-deploy <name>استقرار کلید روی سرور
tunnelforge fingerprint <host>بررسی اثرانگشت سرور

دستورات تلگرام

دستورتوضیح
tunnelforge telegram setupپیکربندی ربات
tunnelforge telegram testارسال پیام آزمایشی
tunnelforge telegram statusنمایش تنظیمات
tunnelforge telegram send <msg>ارسال پیام
tunnelforge telegram reportارسال گزارش وضعیت
tunnelforge telegram share [name]اشتراک اسکریپت‌ها

دستورات سرویس

دستورتوضیح
tunnelforge service <name>تولید سرویس systemd
tunnelforge service <name> enableفعال‌سازی سرویس
tunnelforge service <name> disableغیرفعال‌سازی
tunnelforge service <name> statusوضعیت سرویس
tunnelforge service <name> removeحذف سرویس

دستورات سیستم

دستورتوضیح
tunnelforge menuمنوی تعاملی
tunnelforge installنصب TunnelForge
tunnelforge server-setupسخت‌سازی سرور
tunnelforge obfs-setup <name>راه‌اندازی رمزنگاری TLS
tunnelforge client-config <name>نمایش تنظیمات کلاینت
tunnelforge client-script <name>تولید اسکریپت کلاینت
tunnelforge backupپشتیبان‌گیری
tunnelforge restore [file]بازیابی
tunnelforge uninstallحذف کامل
tunnelforge versionنمایش نسخه
tunnelforge helpراهنما

امنیت

محافظت از نشت DNS

از ارسال درخواست‌های DNS خارج از تانل جلوگیری می‌کند.

نحوه کار:

  1. از /etc/resolv.conf فعلی بکاپ می‌گیرد
  2. آن را با سرورهای DNS امن بازنویسی می‌کند (پیش‌فرض: 8.8.8.8)
  3. فایل را با chattr +i قفل می‌کند تا سیستم نتواند آن را تغییر دهد
  4. هنگام توقف تانل، DNS اصلی بازیابی می‌شود

کیل سوییچ

اگر تانل قطع شود، تمام ترافیک اینترنت مسدود می‌شود.

نحوه کار:

  1. زنجیره iptables سفارشی TUNNELFORGE ایجاد می‌کند
  2. فقط ترافیک تانل SSH + loopback مجاز است
  3. بقیه ترافیک مسدود (IPv4 + IPv6)
  4. هنگام توقف تانل، قوانین حذف می‌شوند

ممیزی امنیتی ۶ نقطه‌ای

tunnelforge audit
بررسیتوضیح
مجوزهای کلید SSHبررسی 600 یا 400 بودن
دایرکتوری SSHتأیید 700 بودن ~/.ssh
محافظت DNSوضعیت محافظت فعال
کیل سوییچفعال بودن زنجیره iptables
سلامت تانلبررسی اعتبار PID‌ها
بسته‌های سیستمابزارهای امنیتی نصب شده

سخت‌سازی سرور

tunnelforge server-setup

تنظیمات:

  • SSH — غیرفعال‌سازی احراز هویت رمز عبور، غیرفعال‌سازی root login
  • فایروال — قوانین UFW/iptables فقط برای SSH + پورت‌های تانل
  • Fail2ban — مسدودسازی خودکار بعد از تلاش‌های ناموفق
  • Kernel — سخت‌سازی sysctl (محافظت SYN flood، ICMP)

رمزنگاری TLS (ضد سانسور)

در شبکه‌هایی که بازرسی عمیق بسته (DPI) دارند، ترافیک SSH قابل شناسایی و مسدودسازی است. TunnelForge اتصال SSH شما را داخل یک لایه TLS می‌پیچد تا مانند ترافیک HTTPS عادی به نظر برسد.

نحوه کار

بدون رمزنگاری TLS:
Client ──── SSH (قابل شناسایی) ────► VPS ← DPI می‌تواند مسدود کند
با رمزنگاری TLS:
Client ──── TLS/443 (شبیه HTTPS) ────► VPS ──── SSH ────► اینترنت

راه‌اندازی سمت سرور

tunnelforge obfs-setup my-tunnel

این دستور به صورت خودکار:

  1. stunnel را روی سرور ریموت نصب می‌کند
  2. گواهی TLS خودامضا تولید می‌کند
  3. پورت 443 (TLS) را به پورت 22 (SSH) مپ می‌کند
  4. سرویس systemd فعال می‌کند
  5. پورت فایروال باز می‌کند

اشتراک‌گذاری با دیگران

# تولید اسکریپت برای Linux + Windows
tunnelforge client-script my-tunnel
# ارسال از طریق تلگرام
tunnelforge telegram share my-tunnel

اسکریپت‌های تولید شده شامل تنظیمات stunnel، فایل PSK و مدیریت کامل اتصال هستند.

کلاینت مستقل ویندوز

فایل windows-client/tunnelforge-client.bat یک کلاینت مستقل ویندوز است که در ریپو موجود است. کاربران فقط دابل‌کلیک می‌کنند، اطلاعات اتصال را وارد می‌کنند و متصل می‌شوند. نیازی به PowerShell نیست.

امکانات:

  • تنظیم تعاملی — سرور، پورت و PSK را می‌پرسد
  • نصب خودکار stunnel (از طریق winget، Chocolatey یا لینک دانلود)
  • ذخیره اتصال برای اتصال مجدد فوری
  • دستورات: tunnelforge-client.bat stop / status
  • نمایش تنظیمات پراکسی مرورگر (Firefox + Chrome)
توزیع:
1. فایل windows-client/tunnelforge-client.bat را به کاربر بدهید
2. اطلاعات PSK + سرور را بدهید (از: tunnelforge client-config <profile>)
3. کاربر دابل‌کلیک → اطلاعات وارد → متصل

ربات تلگرام

اطلاع‌رسانی لحظه‌ای تانل‌ها روی گوشی و کنترل ریموت.

راه‌اندازی

tunnelforge telegram setup
  1. ساخت ربات — به @BotFather پیام دهید و /newbot ارسال کنید
  2. وارد کردن توکن — توکن ربات را در TunnelForge وارد کنید
  3. دریافت Chat ID — به ربات /start ارسال کنید، TunnelForge خودکار شناسایی می‌کند
  4. تمام — پیام آزمایشی تأیید ارسال می‌شود

اعلان‌ها

رویدادپیام
شروع تانلنام، PID، نوع تانل
توقف تانلنام پروفایل
خطای تانلجزئیات خطا
اتصال مجددبازیابی خودکار AutoSSH
هشدار امنیتینشت DNS یا کیل سوییچ
گزارش وضعیتمرور کلی تمام تانل‌ها

دستورات ربات

دستورپاسخ
/tf_statusوضعیت تمام تانل‌ها
/tf_listلیست پروفایل‌ها
/tf_ipIP عمومی سرور
/tf_configتنظیمات اتصال کلاینت
/tf_uptimeمدت فعالیت سرور
/tf_reportگزارش کامل وضعیت
/tf_helpلیست دستورات

سرویس Systemd

تانل‌ها را مقاوم در برابر ریبوت کنید:

tunnelforge service my-tunnel # تولید فایل سرویس
tunnelforge service my-tunnel enable# فعال‌سازی و شروع
tunnelforge service my-tunnel status # بررسی وضعیت
tunnelforge service my-tunnel disable # غیرفعال‌سازی
tunnelforge service my-tunnel remove # حذف سرویس

فایل سرویس تولید شده شامل سخت‌سازی امنیتی (ProtectSystem، PrivateTmp، قابلیت‌های محدود) است.


پشتیبان‌گیری و بازیابی

# پشتیبان‌گیری
tunnelforge backup
# بازیابی
tunnelforge restore
tunnelforge restore /path/to/backup.tar.gz

شامل: پروفایل‌ها، تنظیمات، کلیدهای SSH و فایل‌های سرویس systemd.


سناریوهای واقعی

هر سناریو قابل باز شدن است و مراحل دقیق ویزارد را نشان می‌دهد. هم نسخه SSH معمولی و هم TLS رمزنگاری شده پوشش داده شده.

سناریو ۱: مرور خصوصی با SOCKS5

هدف: ترافیک مرورگر را از طریق VPS مسیریابی کنید تا سایت‌ها IP سرور را ببینند نه IP واقعی شما.

پیش‌نیاز: یک سرور VPS با دسترسی SSH.

مراحل ویزارد (SSH معمولی)

tunnelforge create
مرحلهسوالچه وارد کنید
1Profile nameprivate-proxy
2Tunnel type1 — SOCKS5 Proxy
3SSH hostIP سرور (مثلاً 45.33.32.10)
4SSH port22
5SSH userroot
6SSH passwordرمز عبور (یا Enter برای کلید SSH)
7Identity key~/.ssh/id_ed25519 (یا Enter)
8Auth testخودکار
9aBind address127.0.0.1
9bSOCKS5 port1080
10Connection mode1 — Regular SSH
11Inbound protection1 — None
12AutoSSHy
13Save & starty سپس y

مراحل ویزارد (TLS رمزنگاری — برای شبکه سانسور شده)

مانند بالا، اما در مرحله ۱۰:

مرحلهسوالچه وارد کنید
10Connection mode2 — TLS Encrypted
10aTLS port443 (شبیه HTTPS)
10bSetup stunnel now?y (نصب خودکار روی سرور)

بعد از شروع

Firefox: Settings → proxy → SOCKS Host: 127.0.0.1 Port: 1080

Chrome:

google-chrome --proxy-server="socks5://127.0.0.1:1080"

تست:

curl --socks5-hostname 127.0.0.1:1080 https://ifconfig.me

سناریو ۲: دسترسی به دیتابیس ریموت

هدف: به MySQL/PostgreSQL روی VPS دسترسی پیدا کنید انگار روی سیستم خودتان اجرا می‌شود.

پیش‌نیاز: یک VPS با دیتابیس فعال.

مراحل ویزارد

tunnelforge create
مرحلهسوالچه وارد کنید
1Profile nameprod-db
2Tunnel type2 — Local Port Forward
3SSH hostIP سرور (مثلاً 45.33.32.10)
4SSH port22
5SSH userroot
6SSH passwordرمز عبور
7Identity keyEnter
8Auth testخودکار
9aBind address127.0.0.1
9bLocal port3306 (پورت روی سیستم شما)
9cRemote host127.0.0.1 (یعنی "روی خود VPS")
9dRemote port3306 (پورت MySQL روی VPS)
10Connection mode1 — Regular SSH
11Inbound protection1 — None
12AutoSSHy
13Save & starty سپس y

بعد از شروع

mysql -h 127.0.0.1 -P 3306 -u dbuser -p # MySQL
psql -h 127.0.0.1 -p 5432 -U postgres # PostgreSQL
redis-cli -h 127.0.0.1 -p 6379 # Redis
سرویسپورت محلیپورت ریموت
MySQL33063306
PostgreSQL54325432
Redis63796379
پنل وب80808080

سناریو ۳: اشتراک‌گذاری سرور توسعه

هدف: وب‌سایت محلی (مثلاً پورت 3000) را از طریق VPS در دسترس اینترنت قرار دهید.

پیش‌نیاز: یک سرویس محلی فعال + VPS با IP عمومی.

مراحل ویزارد

tunnelforge create
مرحلهسوالچه وارد کنید
1Profile namedev-share
2Tunnel type3 — Remote/Reverse Forward
3SSH hostIP سرور (مثلاً 45.33.32.10)
4-8SSH credentialsمانند سناریوهای قبل
9aRemote bind0.0.0.0 (دسترسی عمومی)
9bRemote port9090 (پورت روی VPS)
9cLocal host127.0.0.1
9dLocal port3000 (اپ شما)
10Connection mode1 — Regular SSH
12AutoSSHy
13Save & starty سپس y

مهم: اگر bind روی 0.0.0.0 است، باید GatewayPorts yes در sshd سرور فعال باشد.

بعد از شروع

# تست از هرجا:
curl http://45.33.32.10:9090
# لینک اشتراک: http://45.33.32.10:9090

سناریو ۴: عبور از چند فایروال (Jump Host)

هدف: به سروری که مستقیماً از اینترنت قابل دسترسی نیست از طریق سرورهای واسط (bastion) دسترسی پیدا کنید.

مراحل ویزارد (SOCKS5 در مقصد)

tunnelforge create
مرحلهسوالچه وارد کنید
1Profile namecorp-access
2Tunnel type4 — Jump Host
3SSH hostIP مقصد (مثلاً 10.0.50.100)
4SSH port22
5SSH useradmin (کاربر روی مقصد)
6SSH passwordرمز مقصد
8Auth testممکن است خطا بدهد — ادامه دهید
9aJump hostsroot@bastion.example.com:22
9bTunnel type at destination1 — SOCKS5
9cBind address127.0.0.1
9dSOCKS5 port1080
10Connection mode1 — Regular SSH
13Save & starty سپس y

مهم: مراحل ۳ تا ۷ برای سرور مقصد هستند. اطلاعات سرور واسط در مرحله 9a وارد می‌شود.

چند سرور واسط

Jump hosts: user1@hop1.com:22,user2@hop2.com:22

سناریو ۵: عبور از سانسور DPI (یک VPS)

هدف: ISP شما SSH را شناسایی و مسدود می‌کند. SSH را در TLS بپیچید تا مانند HTTPS عادی به نظر برسد.

بدون TLS: PC ──── SSH (مسدود توسط DPI) ────► VPS
با TLS: PC ──── TLS/443 (شبیه HTTPS) ────► VPS ──► Internet

مراحل ویزارد

tunnelforge create
مرحلهسوالچه وارد کنید
1Profile namebypass-proxy
2Tunnel type1 — SOCKS5 Proxy
3SSH hostIP سرور خارج از کشور
4-8SSH credentialsمانند سناریوهای قبل
9aBind address127.0.0.1
9bSOCKS5 port1080
10Connection mode2 — TLS Encrypted
10aTLS port443 (شبیه HTTPS)
10bSetup stunnel?y (نصب خودکار)
11Inbound protection1 — None
12AutoSSHy
13Save & starty سپس y

DPI چه می‌بیند

PC ──── HTTPS:443 ──► VPS IP
نتیجه: ترافیک عادی وب. مجاز.

سناریو ۶: زنجیره دو سرور TLS

هدف: پراکسی اشتراکی برای چند کاربر. VPS-A = ورودی (relay). VPS-B = خروجی. هر دو مسیر TLS رمزنگاری شده.

Users ── TLS+PSK:1443 ──► VPS-A ── TLS:443 ──► VPS-B ──► Internet

مراحل ویزارد (اجرا روی VPS-A)

tunnelforge create
مرحلهسوالچه وارد کنید
1Profile namedouble-hop
2Tunnel type1 — SOCKS5
3SSH hostIP VPS-B
4-8SSH credentialsاطلاعات VPS-B
9aBind address127.0.0.1
9bSOCKS5 port1080
10Connection mode2 — TLS Encrypted
10aTLS port443
10bSetup stunnel on VPS-B?y
11Inbound protection2 — TLS + PSK
11aInbound TLS port1443
11bPSKخودکار تولید می‌شود
12AutoSSHy
13Save & starty سپس y

تولید اسکریپت برای کاربران

tunnelforge client-script double-hop # تولید اسکریپت
tunnelforge telegram share double-hop # ارسال با تلگرام

کاربران چه می‌کنند

# Linux:
./tunnelforge-connect.sh # اتصال
./tunnelforge-connect.sh stop # قطع# پراکسی مرورگر: 127.0.0.1:1080
# Windows PowerShell:
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1
# پراکسی مرورگر: 127.0.0.1:1080
# Windows Batch (کلاینت مستقل):
tunnelforge-client.bat # دابل‌کلیک، سرور/پورت/PSK وارد کنید
tunnelforge-client.bat stop # قطع
tunnelforge-client.bat status # بررسی
# پراکسی مرورگر: 127.0.0.1:1080

سناریو ۷: اشتراک تانل با دیگران

هدف: تانل TLS+PSK فعال دارید و می‌خواهید دیگران هم استفاده کنند. TunnelForge یک اسکریپت مستقل تولید می‌کند.

پیش‌نیاز: تانل فعال با Inbound TLS+PSK (سناریو ۵ یا ۶).

مرحله ۱ — تولید اسکریپت

tunnelforge client-script my-tunnel

دو فایل تولید می‌شود:

  • tunnelforge-connect.sh — برای Linux/Mac
  • tunnelforge-connect.ps1 — برای Windows PowerShell

یا از کلاینت مستقل ویندوز استفاده کنید: فایل windows-client/tunnelforge-client.bat را از ریپو به کاربر بدهید — فقط دابل‌کلیک، اطلاعات اتصال وارد، متصل. نیازی به تولید اسکریپت نیست.

مرحله ۲ — ارسال به کاربران

tunnelforge telegram share my-tunnel # ارسال با تلگرام

یا از طریق واتس‌اپ، ایمیل، فلش و غیره.

برای کاربران ویندوز: فایل windows-client/tunnelforge-client.bat را هم بفرستید (یا فقط فایل bat با اطلاعات PSK کافیست).

مرحله ۳ — اجرا توسط کاربر

# Linux:
chmod +x tunnelforge-connect.sh
./tunnelforge-connect.sh # اتصال (stunnel خودکار نصب می‌شود)
./tunnelforge-connect.sh stop # قطع
./tunnelforge-connect.sh status # بررسی وضعیت# پراکسی مرورگر: 127.0.0.1:1080
# Windows PowerShell:
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1 stop
powershell -ExecutionPolicy Bypass -File tunnelforge-connect.ps1 status
# پراکسی مرورگر: 127.0.0.1:1080
# Windows Batch (کلاینت مستقل):
tunnelforge-client.bat # دابل‌کلیک، سرور/پورت/PSK وارد کنید
tunnelforge-client.bat stop # قطع
tunnelforge-client.bat status # بررسی
# پراکسی مرورگر: 127.0.0.1:1080

لغو دسترسی کاربر

  1. PSK را در پروفایل تغییر دهید
  2. اسکریپت جدید تولید کنید: tunnelforge client-script my-tunnel
  3. تانل را ریستارت کنید: tunnelforge restart my-tunnel
  4. اسکریپت‌های قدیمی دیگر کار نمی‌کنند

منوی یادگیری

TunnelForge شامل سیستم آموزشی تعاملی است (کلید l در منوی اصلی):

#موضوعتوضیح
۱تانل SSH چیست؟مبانی کانال رمزنگاری شده
۲پراکسی SOCKS5مسیریابی ترافیک با -D
۳Port Forwarding محلیدسترسی به سرویس ریموت با -L
۴Port Forwarding معکوسنمایش سرویس محلی با -R
۵Jump Hostعبور از سرورهای واسط با -J
۶ControlMasterاستفاده مجدد از اتصالات
۷AutoSSHبازیابی خودکار تانل
۸رمزنگاری TLSپوشش SSH در TLS
۹احراز هویت PSKکلید پیش‌اشتراکی

مجوز و نویسنده

TunnelForge تحت مجوز GNU General Public License v3.0 منتشر شده است.

حق نشر (C) ۲۰۲۶ SamNet Technologies, LLC

💖 Support

If this project helps you, consider supporting continued development:

samnet.dev/donate

About

The ultimate single-file SSH tunnel manager. Full TUI, live dashboard, TLS obfuscation, Telegram bot, kill switch, and more. Zero dependencies.

Topics

Resources

Stars

109 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages