Server for doing registration-based reverse port forwardings to a public port using SSH tunneling. Works with all protocols, not just HTTP. No client component required as MyTurn implementes an SSH-based API.
  • Go 97.6%
  • Dockerfile 2.4%
Find a file
Leon Schmidt 5f27232991
Some checks failed
/ docker-build-and-push (push) Has been cancelled
/ go-test (push) Has been cancelled
fix: package registry URLs [ci-skip]
2026-04-14 21:05:03 +02:00
.forgejo/workflows chore: migrated from Gitlab CI/CD to Forgejo Actions 2026-04-14 20:40:33 +02:00
.gitignore Added help command 2024-08-23 15:24:41 +02:00
commands.go Implemented multiple keys, all commands and a database access layer 2024-08-23 18:00:28 +02:00
config.example.json Fixed formatting 2024-07-17 14:38:44 +02:00
config.go Implemented registration secret, closes #6 2024-07-17 14:37:14 +02:00
database.go Implemented multiple keys, all commands and a database access layer 2024-08-23 18:00:28 +02:00
docker-compose.yml fix: package registry URLs [ci-skip] 2026-04-14 21:05:03 +02:00
Dockerfile Bumped everything to go1.23 2024-08-24 11:32:35 +02:00
go.mod Bumped everything to go1.23 2024-08-24 11:32:35 +02:00
go.sum Updated packets 2024-08-23 18:00:36 +02:00
LICENSE Added LICENSE 2025-08-11 21:00:48 +02:00
main.go Implemented multiple keys, all commands and a database access layer 2024-08-23 18:00:28 +02:00
prompts.go Implemented multiple keys, all commands and a database access layer 2024-08-23 18:00:28 +02:00
README.md fix: package registry URLs [ci-skip] 2026-04-14 21:05:03 +02:00
ssh_auth.go Implemented multiple keys, all commands and a database access layer 2024-08-23 18:00:28 +02:00
ssh_port_forwarding.go Closed #2 2024-01-18 18:10:25 +01:00
utils.go Implemented multiple keys, all commands and a database access layer 2024-08-23 18:00:28 +02:00
utils_test.go Added help command 2024-08-23 15:24:41 +02:00

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.json to data/config.json and adjust the values (see "config.json" below)
  • Adjust the port mappings in docker-compose.yml accordingly
  • 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 -i flag the SSH agent selects one of your keys for you
  • 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 page
  • get-keys: Gets a list of all your public keys with their IDs
  • add-key <key>: Adds a new key to your account
  • remove-key <key-id>: Removes a key by it's key ID displayed in get-keys

Commands in MyTurn port forwarding terminal

  • help: Shows a help page
  • status: Unimplemented
  • stop: Closes the connection and deallocates the port