SSH Channels Hub
A CLI application to create and manage SSH channels (port forwarding over SSH).
Cross-platform (Windows, Linux), written in Rust.
Features
- Port forwarding: Listen on local ports and forward traffic to remote hosts via SSH tunnels (direct-tcpip).
- Hosts + channels: Define SSH hosts once, then reference them in channel configs (hostname, ports, dest_host, listen_host).
- Automatic reconnection: Reconnect with configurable backoff when the connection is lost.
- Foreground / daemon: Default
startruns in foreground;start -Druns as daemon (detached). Stop and restart use IPC so the process exits cleanly. - Config validation: Validate config file; generate config from
~/.ssh/config.
Usage
Installation
Build from source:
The binary will be at target/release/ssh-channels-hub (or ssh-channels-hub.exe on Windows).
Configuration
-
Config file location (default; first existing wins):
- Current directory:
./configs.toml - Linux/macOS:
~/.config/ssh-channels-hub/config.toml - Windows:
%APPDATA%\ssh-channels-hub\config.toml
- Current directory:
-
Copy the example config:
# or into platform dir: -
Edit the file with your hosts and channels. Use
--config /path/to/config.tomlto override. See Configuration for details.
Basic Commands
Start the service
Foreground (default; press Ctrl+C to stop):
Daemon (background; spawns detached process):
# or
Custom config:
Debug logging:
Stop the service
Sends a stop signal via IPC so the service exits gracefully, then removes run files (.pid, .port). Use the same --config as start if you use a non-default config.
Restart the service
Stops the running service (via IPC if running), then starts it again as a daemon. Use the same --config as the running service.
Check service status
Connects to the running process via IPC and shows state (with emoji), active channels, config path, PID, and channel list. If the service is not running, shows Stopped and channel list from config.
Test channels
Test that configured channels are reachable (connect to local ports):
Validate configuration
Generate configuration from SSH config
Generate a config from ~/.ssh/config:
The generated file contains [[hosts]] entries. Add [[channels]] sections (hostname, ports, optional dest_host / listen_host) for port forwarding.
Configuration format (summary)
- Hosts (
[[hosts]]):name,host,port,username,auth(key or password). - Channels (
[[channels]]):name,hostname(must match a host),ports. Optional:channel_type,dest_host,listen_host.- Local forward (default, like
ssh -L):ports = "local:dest"(e.g."80:3923"= listen local 80 → remote 3923). - Remote forward (like
ssh -R):channel_type = "forwarded-tcpip",ports = "remote:local"(e.g."8022:80"= bind 8022 on server → connect to local 127.0.0.1:80).
- Local forward (default, like
- Optional per channel:
dest_host(default127.0.0.1),listen_host(default127.0.0.1; use0.0.0.0for all interfaces; local forward only).
Configuration examples
Port forwarding (local 8080 → remote 80)
[[]]
= "web-server"
= "example.com"
= 22
= "user"
[]
= "key"
= "~/.ssh/id_rsa"
[[]]
= "web-tunnel"
= "web-server"
= "8080:80"
= "127.0.0.1"
# listen_host = "127.0.0.1" # default; use "0.0.0.0" to allow other machines to connect
Port forwarding (listen on all interfaces)
[[]]
= "db-tunnel"
= "db-server"
= "3306:3306"
= "127.0.0.1"
= "0.0.0.0"
Remote port forwarding (ssh -R style)
Expose a local service on the SSH server: bind a port on the server and bridge connections to a local address.
[[]]
= "expose-local-web"
= "forwarded-tcpip"
= "web-server"
= "8022:80" # remote port 8022 -> local 127.0.0.1:80
= "127.0.0.1" # local host to connect to (default)
Common use cases
- Secure DB access: Forward local 3306 to remote MySQL (e.g.
ports = "3306:3306"). - Remote web service: Forward local 8080 to remote 80 (e.g.
ports = "8080:80"). - Remote forward (ssh -R): Expose local service on server (e.g.
channel_type = "forwarded-tcpip",ports = "8022:80"). - Multiple tunnels: Define several channels; all start together and reconnect independently.
- Expose to LAN: Set
listen_host = "0.0.0.0"so other machines can use the tunnel (consider firewall and security).
Troubleshooting
- Connection fails: Check SSH credentials and network; try
ssh user@hostmanually. - Port in use: Change
ports(e.g. use 18080 instead of 80) or stop the app using the port. - Bind 80 on Windows: Often requires running as Administrator.
- Config errors: Run
ssh-channels-hub validate. - Debug: Use
ssh-channels-hub start --debugor--debugwith any command. - Key permissions: Ensure SSH key file has correct permissions (e.g. 600).
More details: Documentation, How to use, Configuration.