- Go 97.6%
- Dockerfile 2.4%
| .forgejo/workflows | ||
| .gitignore | ||
| commands.go | ||
| config.example.json | ||
| config.go | ||
| database.go | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| prompts.go | ||
| README.md | ||
| ssh_auth.go | ||
| ssh_port_forwarding.go | ||
| utils.go | ||
| utils_test.go | ||
MyTurn - SSH Port Forwarding Server
Setup
You can use the provided docker-compose.yml and the prebuilt Docker image at code.leon.wtf/leon/myturn. You need to make the following adjustments:
- Copy
config.example.jsontodata/config.jsonand adjust the values (see "config.json" below) - Adjust the port mappings in
docker-compose.ymlaccordingly - Make sure the specified ports are accessible, e.g. configure your networks firewall to allow incomping packets on the specified port range and the SSH port
config.json
| Key | Description |
|---|---|
service_addr |
Where the application INSIDE the Docker container should listen on. |
external_service_hostname |
Hostname where MyTurn is accessible externally. |
external_service_port |
Port where MyTurn is accessible externally. |
port_range_start |
Start of the port range, users can bind their services to. |
port_range_end |
End of the port range, users can bind their services to. |
registration_secret |
A secret, users must enter when they want to register. If not set, the registration does not require a secret. |
host_key_path |
The private host key MyTurn should use for itself. |
How to use it?
MyTurn uses your SSH public key and a chosen username to identify you. You need to register youself, via the register user:
ssh -p <port> [-i <path-to-ssh-key>] register@<hostname>, e.g.ssh -p 222 register@myturn.example.org- If you don't specify the
-iflag the SSH agent selects one of your keys for you
- If you don't specify the
- Enter the registration secret (if configured)
- Enter your wanted username
You can then use your username to request a port forwarding:
ssh -p <port> [-i <path-to-ssh-key>] -R 0.0.0.0:<public-port>:127.0.0.1:<local-port> <username>@<myturn.example.org, e.g.ssh -p 222 -R 0.0.0.0:6101:127.0.0.1:8080 leon@myturn.example.org
MyTurn verifies your SSH key and, if authenticated, opens a virutal terminal to control (e.g. stop) the port forwarding. The connection needs to stay open as long as you want to use the SSH port forwarding.
SSH commands
You can manage your SSH keys via SSH commands. This allows you to add multiple keys to your account. Execute a command with: ssh -p <port> [-i <path-to-ssh-key>] <username>@<hostname> <command>.
These commands are available:
help: Shows a help pageget-keys: Gets a list of all your public keys with their IDsadd-key <key>: Adds a new key to your accountremove-key <key-id>: Removes a key by it's key ID displayed inget-keys
Commands in MyTurn port forwarding terminal
help: Shows a help pagestatus: Unimplementedstop: Closes the connection and deallocates the port