SSH Tunnel Manager (sshtm) is a CLI and background daemon for saving, starting, listing, and stopping SSH local port-forwarding tunnels. It is useful when you frequently connect to the same private services through SSH and want reusable tunnel profiles instead of typing long ssh -L commands.
Current version: v1.1.5
- Manages reusable SSH tunnel configurations with names and descriptions.
- Starts tunnels from saved configurations, equivalent to:
ssh -L [LOCAL_IP:]LOCAL_PORT:DESTINATION:DESTINATION_PORT [USER@]SSH_SERVER
- Runs through a background daemon (
sshtmd) that the CLI (sshtm) communicates with over gRPC.
-
Go 1.25 or later for building from source.
-
Git for cloning the repository.
-
systemd user services on Linux or LaunchAgents on macOS for the installed daemon service.
-
Air (optional) for live reload during development.
git clone https://github.com/besrabasant/ssh-tunnel-manager.git
cd ssh-tunnel-manager
./install.shThe install script builds the daemon and CLI for your OS/architecture, then installs them under ~/.local/bin.
Installed paths:
| Purpose | Path |
|---|---|
| CLI binary | ~/.local/bin/sshtm |
| Daemon binary | ~/.local/bin/sshtmd |
| Data/config directory | ~/.ssh-tunnel-manager |
| Helper scripts | ~/.local/share/sshtm/scripts |
Service behavior:
- Linux: installs and starts a systemd user unit for
sshtmd. - macOS: installs and starts a LaunchAgent for
sshtmd.
Make sure ~/.local/bin is on your PATH after installation.
If you use yay, install directly from the AUR:
yay -S sshtmYou can also build the package manually with makepkg inside packaging/arch.
Build a Debian package using the files in packaging/debian:
cd packaging/debian
dpkg-buildpackage -us -uc
sudo dpkg -i ../sshtm_1.1.5-1_amd64.debIf installed from source, run:
~/.local/share/sshtm/scripts/uninstall.sh-
Add a tunnel configuration interactively:
sshtm add
-
List saved configurations:
sshtm list
-
Start a saved tunnel:
sshtm tunnel my_configuration
-
Start a saved tunnel with an explicit local port:
sshtm tunnel my_configuration 8080
-
View active tunnels:
sshtm active
-
Stop a tunnel by name or local port:
sshtm kill my_configuration sshtm kill 8080
When adding or editing a tunnel, sshtm stores these fields:
| Field | Description |
|---|---|
name |
Unique name for the tunnel configuration. |
description |
Human-readable notes about the tunnel. |
server |
SSH server or jump host. |
user |
SSH username. |
key_file |
Private key file used for authentication. |
remote_host |
Destination host reached from the SSH server. |
remote_port |
Destination port on the remote host. |
local_port |
Local port to bind when starting the tunnel. |
sshtm [command]| Command | Aliases | Description |
|---|---|---|
list [search pattern] |
ls, l |
List saved SSH tunnel configurations, optionally filtered with fuzzy search. |
add |
a |
Add a new SSH tunnel configuration using an interactive form. |
edit |
e |
Edit an existing SSH tunnel configuration. |
delete |
del, d |
Delete an existing SSH tunnel configuration. |
tunnel <configuration name> [local port] |
t |
Start an SSH tunnel from a saved configuration, optionally overriding the local port. |
active |
List active SSH tunnels. | |
kill <configuration name or local port> |
k, terminate |
Terminate an active SSH tunnel. |
completion |
Generate shell completion scripts. | |
version |
Print the version number. | |
help [command] |
Show command help. |
Use sshtm help <command> for command-specific details.
make gen_protomake gen_proto
airThis assumes Air is installed and the command is run from the project root.
cd client
go run main.go [command] [arguments]For example:
cd client
go run main.go listmake buildThis creates:
./sshtmdfor the daemon../sshtmfor the CLI.
The Makefile includes targets for Linux and macOS:
make build_linux # linux/amd64
make build_macos # darwin/amd64 + darwin/arm64
make build_all # linux + macosYou can pass an explicit version into builds:
make VERSION=1.1.5 build_allgo test ./...client/ CLI commands, terminal forms, and daemon client helpers
daemon/ Background daemon and gRPC server task handlers
pkg/ Reusable configuration and tunnel-management packages
rpc/ Protobuf definitions and generated gRPC code
config/ Application constants and version metadata
packaging/ Arch Linux and Debian packaging files
scripts/ Install/uninstall helper scripts
utils/ Shared utility helpers
This project uses Semantic Versioning for version numbers.
This project is licensed under the MIT License.