2025-05-23 15:08:44 +02:00
2025-05-23 15:08:44 +02:00
2025-05-23 15:08:44 +02:00
2025-05-23 15:08:44 +02:00
2025-05-23 15:08:44 +02:00
2025-05-23 15:08:44 +02:00
2025-05-23 15:08:44 +02:00
2025-05-23 15:08:44 +02:00
2025-05-23 15:16:47 +02:00

SSH Tunnel Manager

A Go-based command-line tool to manage SSH tunnels. This tool allows you to:

  • List currently active SSH tunnels
  • Start new SSH tunnels as background daemons
  • Stop running SSH tunnels
  • Monitor traffic statistics for SSH tunnels

Installation

go install git.mvl.sh/vleeuwenmenno/sshtunnel/cmd@latest

Or clone this repository and build it yourself:

git clone https://git.mvl.sh/vleeuwenmenno/sshtunnel.git
cd sshtunnel
go build -o sshtunnel ./cmd

Usage

Listing active tunnels

sshtunnel list

This will display all active SSH tunnels with their IDs, local ports, remote endpoints, and process IDs.

Starting a new tunnel

sshtunnel start -l 8080 -r 80 -H example.com -s user@ssh-server.com

Options:

  • -l: Local port to forward (required)
  • -r: Remote port to forward to (required)
  • -H: Remote host to forward to (default: "localhost")
  • -s: SSH server address in the format user@host (required)
  • -i: Path to SSH identity file (optional)

Stopping tunnels

Stop a specific tunnel by ID:

sshtunnel stop -i 1

Stop all active tunnels:

sshtunnel stop --all

Options:

  • -i: ID of the tunnel to stop
  • --all: Stop all tunnels

Viewing traffic statistics

View statistics for all tunnels:

sshtunnel stats --all

View statistics for a specific tunnel:

sshtunnel stats -i 1

Monitor tunnel traffic in real-time:

sshtunnel stats -i 1 --watch

Options:

  • --id: ID of the tunnel to show statistics for
  • --all: Show statistics for all tunnels
  • --watch: Continuously monitor statistics (only with specific tunnel ID)
  • --interval: Update interval in seconds for watch mode (default: 5)

Debugging tunnels

Run diagnostics to troubleshoot issues with SSH tunnels:

sshtunnel debug

This command will:

  1. Check if SSH client is properly installed
  2. Verify the tunnel directory exists and is accessible
  3. Validate all recorded tunnels and their current state
  4. Show active SSH tunnel processes and their status

How it works

The tool creates SSH tunnels using the system's SSH client and manages them by tracking their process IDs in a hidden directory (~/.sshtunnels/). Each tunnel is assigned a unique ID for easy management. Traffic statistics are collected and stored to help you monitor data transfer through your tunnels.

Requirements

  • Go 1.16 or higher
  • SSH client installed on your system

License

MIT

Description
No description provided
Readme 87 KiB
Languages
Go 77.3%
Shell 22%
Makefile 0.7%