Skip to content

Repository files navigation

SSH Tunnel

example.mp4

this could've been a small bash script 💩

If you are like me and can't remember the ssh tunnel command to reach your services behind a firewall

as in:

ssh -L 8080:localhost:8080 user@server -N

Then this highly overengineered tool will help you to never worry about it again.

Write a config specifying the tunnel(s) needed:

ℹ️ TIP see the example.ssh-tunnel.hcl file

// tunnel 1tunnel {
user="user"local {
port=8080
}
remote {
host="server:22"port=8080
}
}
// tunnel 2tunnel {
user="user"local {
port=8081
}
remote {
host="server:22"port=8081
}
}

and run

ssh-tunnel
# Remote Host Tunnel# user@server:22 127.0.0.1:8080 -> 127.0.0.1:8080# user@server:22 127.0.0.1:8081 -> 127.0.0.1:8081
ssh-tunnel --help
# Usage of ./ssh-tunnel:# -config string# The config file to use (default "ssh-tunnel.hcl")# -debug# Print debug output# -init# Create a new config file# -no-color# Disable color output# -version# Print the version and exit

Prerequisites

ssh-tunnel uses your SSH Agent (SSH_AUTH_SOCK) to create the tunnels, it does not work without it!

Here's a quick guide to setting up an SSH Agent on linux (and WSL2)

sudo apt update
sudo apt install keychain
echo"eval `keychain --eval --agents ssh id_rsa`">>~/.profile
source~/.profile

Installation

Either download it from the releases page

or install it with go

go install github.com/inveracity/ssh-tunnel/cmd/ssh-tunnel@latest
ssh-tunnel --version

Build

make ssh-tunnel
# ./ssh-tunnel --help

or make install to install the binary directly into ~/.local/bin (make sure this exists in your PATH)

Limitations

It does not work on Windows except WSL2, and is not tested on macOS.

About

ssh-tunnel is an overengineered ssh wrapper for making tunnels to services on your server

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages