Skip to content

jmsperu/tunl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tunl

SSH tunnel manager. Save, start, and manage local, remote, and dynamic (SOCKS5) port forwarding tunnels. Auto-reconnect, jump host support, and named configurations. Single binary, no dependencies.

Works on Windows, macOS, and Linux.

Features

  • Local forwarding (-L) -- forward a local port to a remote host through SSH
  • Remote forwarding (-R) -- expose a local service on a remote server
  • Dynamic forwarding (-D) -- SOCKS5 proxy through SSH
  • Named tunnels -- save tunnel configs and start them by name
  • Auto-reconnect -- automatically reconnects on disconnect
  • Jump hosts -- connect through bastion/jump servers
  • Key and password auth -- supports SSH keys (auto-detected) and passwords

Install

Binary download

Grab the latest binary from Releases and place it in your PATH.

Go install

go install github.com/jmsperu/tunl@latest

Build from source

git clone https://github.com/jmsperu/tunl.git
cd tunl
make build

Cross-compile for all platforms:

make build-all    # outputs to dist/

Quick start

# Forward local port 3306 to a remote database through a bastion host
tunl start -L 3306:db.internal:3306 user@bastion

# Save it for later
tunl add db -L 3306:db.internal:3306 user@bastion

# Start by name
tunl up db

Commands

tunl start

Start a tunnel immediately (not saved).

tunl start -L 3306:db.internal:3306 user@bastion       # local forward
tunl start -R 8080:localhost:3000 user@server           # remote forward
tunl start -D 1080 user@proxy                           # SOCKS5 proxy
tunl start -L 5432:pg:5432 user@bastion -J jump@gateway # via jump host
tunl start -L 3306:db:3306 user@host -k ~/.ssh/id_rsa   # specific key
tunl start -L 3306:db:3306 user@host -p mypassword       # password auth

tunl add

Save a tunnel configuration for reuse.

tunl add db -L 3306:db.internal:3306 user@bastion
tunl add web -R 8080:localhost:3000 user@server -d "expose dev server"
tunl add proxy -D 1080 user@proxy

tunl up

Start a saved tunnel by name.

tunl up db
tunl up proxy

tunl list (alias: ls)

List all saved tunnels.

tunl list

tunl remove (alias: rm)

Remove a saved tunnel.

tunl remove db

Flags reference

Flag Short Description
--local -L Local forward (localPort:remoteHost:remotePort)
--remote -R Remote forward (remotePort:localHost:localPort)
--dynamic -D SOCKS5 dynamic port
--key -k SSH private key file
--password -p SSH password
--jump -J Jump host (user@host:port)
--desc -d Tunnel description (for add only)

Config file

Tunnels are saved to ~/.tunl.yml:

tunnels:
  db:
    type: local
    host: bastion.example.com
    port: 22
    user: admin
    key_file: ~/.ssh/id_ed25519
    local_port: 3306
    remote_addr: db.internal
    remote_port: 3306
    auto_reconnect: true
    description: Production database
  proxy:
    type: dynamic
    host: proxy.example.com
    user: admin
    local_port: 1080
    auto_reconnect: true

License

MIT

About

SSH tunnel manager — save, start, and manage port forwarding tunnels. Single binary.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors