itzg / rcon-hub

Provides an SSH server that enables rcon connections to configured game servers
MIT License
10 stars 1 forks source link
rcon ssh-server

GitHub issues Docker Pulls GitHub release CircleCI Buy me a coffee

Provides an SSH server that enables rcon connections to configured game servers

Configuration

Create a YAML file named config.yml and place it in the current directory, /etc/rcon-hub, or in a .rcon-hub directory located in your home directory.

Top-level keys of the configuration include:

On Windows you can generate a host key file using PuTTY Key Generator and exporting the private key without a password using the "Conversions > Export OpenSSH key" menu.

On Linux you can generate a host key file using ssh-keygen.

Users

One or more users can be declared under the users key with a key-object entry each. The sub-key is the username and object requires:

Connections

One or more RCON connections can be declared under the connections key with a key-object entry each. The sub-key is the name of the connection that will be used with the hub's connect command. The object requires:

Example

The following example declares one SSH user with the username testing and a password of pw. It also declares a single RCON connection named local-mc that will connect to localhost:25575 with the password minecraft.

users:
  testing:
    password: pw
connections:
  mc:
    address: localhost:25575
    password: minecraft
host-key-file: host_key.pem

Usage

With the configuration described above, start the hub:

rcon-hub

Passing help or --help will display additional command-line options.

Docker Usage

A containerized version is provided at itzg/rcon-hub. It exposes the SSH port at 2222 and declares two volumes:

Rather than using the config file, the following environment variables are supported:

For example, the following starts a container with the same user and connection as the YAML file above

docker run -d --name rcon-hub -p 2222:2222 \
  -e RH_USER=testing -e RH_PASSWORD=pw -e RH_CONNECTION=mc=minecraft@localhost:25575 \
  itzg/rcon-hub

To ensure the generated host key persists across restarts, be sure to attach the /data volume, such as with this Docker compose file:

version: "3.7"

services:
  rcon-hub:
    image: itzg/rcon-hub
    environment:
      RH_USER: testing
      RH_PASSWORD: pw
      RH_CONNECTION: mc=minecraft@mc:25575
    ports:
      - 2222:2222
    volumes:
      - rcon-hub:/data
volumes:
  # declare volume with default volume engine
  rcon-hub: {}

A full example is located at examples/docker-compose.yml

Connecting

You can connect to the running hub server using any ssh client and using password authentication, such as:

ssh -p 2222 testing@localhost

Shell usage

Once connected, you interact with a simple shell environment. The help command lists the other commands available within the shell. The command history can be accessed by pressing the up/down arrow keys.