|
1 | 1 | # sshgate |
| 2 | + |
| 3 | +sshgate is a proxy SSH server/firewall built to run at a network boundary. It takes a JSON config file that defines the hosts and ports that SSH identities can reach. |
| 4 | + |
| 5 | +I made this for my experimental [devenv](https://github.com/cedws/devenv) project in which I'm building a locked down development environment with restricted outbound traffic. sshgate facilitates my goal of only allowing outbound SSH traffic to `github.com:22`. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +sshgate is an SSH server that only handles `direct-tcpip` channels, meaning it will only opaquely forward traffic from a remote host if there's a rule for the connected identity allowing it. It doesn't grant a PTY. |
| 10 | + |
| 11 | +Copy the example `config.json` and add your own SSH public key to the `authorized_keys` array, then start it up: |
| 12 | + |
| 13 | +``` |
| 14 | +sshgate --config config.json |
| 15 | +``` |
| 16 | + |
| 17 | +You can now use it as a jump host to reach a remote host: |
| 18 | + |
| 19 | +``` |
| 20 | +ssh -J localhost:2222 [email protected] |
| 21 | +``` |
| 22 | + |
| 23 | +The example config contains a rule allowing the client to jump to `github:22`. If you try some other host or port, you'll see something like this: |
| 24 | + |
| 25 | +``` |
| 26 | +$ ssh -J localhost:2222 bitbucket.org |
| 27 | +channel 0: open failed: administratively prohibited: remote connection rejected |
| 28 | +stdio forwarding failed |
| 29 | +Connection closed by UNKNOWN port 65535 |
| 30 | +``` |
| 31 | + |
| 32 | +sshgate doesn't care about the username used for the jump hop. It doesn't care about the usernames in subsequent hops either; that information is opaque, it simply forwards the traffic to the client. |
| 33 | + |
| 34 | +Since we didn't pass any SSH host keys to sshgate earlier, it generated an ephemeral ED25519 host key on startup. For the server to have a persistent identity, generate an SSH keypair and set `SSHGATE_HOST_KEY_PATH_*` to the path of the private key. |
| 35 | + |
| 36 | +For example, to set the server's ED25519 identity: |
| 37 | + |
| 38 | +``` |
| 39 | +ssh-keygen -t ed25519 -f sshgate |
| 40 | +export SSHGATE_HOST_KEY_PATH_ED25519=./sshgate |
| 41 | +``` |
| 42 | + |
| 43 | +You can also set an RSA and ECDSA identity if you wish. |
| 44 | + |
| 45 | +- `SSHGATE_HOST_KEY_PATH_RSA` |
| 46 | +- `SSHGATE_HOST_KEY_PATH_ED25519` |
| 47 | +- `SSHGATE_HOST_KEY_PATH_ECDSA` |
0 commit comments