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 -NThen 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.hclfile
// 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:8081ssh-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 exitssh-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~/.profileEither download it from the releases page
or install it with go
go install github.com/inveracity/ssh-tunnel/cmd/ssh-tunnel@latest
ssh-tunnel --versionmake ssh-tunnel
# ./ssh-tunnel --helpor make install to install the binary directly into ~/.local/bin (make sure this exists in your PATH)
It does not work on Windows except WSL2, and is not tested on macOS.