ssh-tunnel

module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: MIT

README

SSH Tunnel

https://user-images.githubusercontent.com/8753040/252415448-7dafba47-13cc-4669-b891-1b7f9e9935ed.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 1
tunnel {
    user = "user"
    local {
        port = 8080
    }
    remote {
        host = "server:22"
        port = 8080
    }
}

// tunnel 2
tunnel {
    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

#  -config string
#        The config file to use (default "ssh-tunnel.hcl")
#  -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 /usr/local/bin

Limitations

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

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL