2 stable releases

new 1.1.0 Mar 9, 2025
1.0.0 Mar 9, 2025

#633 in Network programming

Custom license

24KB
414 lines

RCON Client (rconc)

A simple command-line RCON (Remote Console) client.

RCON is a protocol used to remotely execute commands on a game server, typically used for administrative tasks. This client allows you to connect to an RCON server and send commands from the command line.

RCON is used for many popular games, such as:

  • Minecraft
  • Counter-Strike: Global Offensive
  • Rust
  • Team Fortress 2
  • ARK: Survival Evolved
  • and many more…

Features

This crate is intentionally left “featureless”. It is simple, and perfect for scripting, for example in CRON jobs. It features two modes:

  1. “One-shot” mode: Send a single command, a CLI argument, and exit.
  2. “Online” mode: Continuously send commands obtained through the standard input, and exit on EOF.

Both modes can be used in scripts.

Usage

One-shot Mode

rconc <host> <port> --password-file=<PWD> -- <command>

For example, to list all players on a Minecraft server:

rconc example.org 25575 --password-file /run/secrets/rcon_password -- list

Online Mode

rconc <host> <port> --password-file=<PWD>

For example, to give everyone a diamond, a free emerald, and a free netherite sword:

rconc example.org 25575 --password-file /run/secrets/rcon_password <<EOF
give @a diamond
give @a emerald
give @a netherite_sword
EOF

Password Management

There are four ways to provide the RCON password:

  1. rconc … --password=<PWD>: Provide the password directly.
  2. rconc … --password-file=<PATH>: Read the password from a file.
  3. RCON_PASSWORD=<PWD> rconc …: Read the password from the RCON_PASSWORD environment variable.
  4. RCON_PASSWORD_FILE=<PATH> rconc …: Read the password from the file specified in the RCON_PASSWORD_FILE environment variable.

Especially when scripting, it is recommended to pass the password through a properly secured file.

Command-Line Options

Simply run rconc --help to see the available options:

A simple RCON client.

Usage: rconc [OPTIONS] <--password <PASSWORD>|--password-file <PASSWORD_FILE>> <HOST> <PORT> [COMMAND]...

Arguments:
  <HOST>        RCON server host
  <PORT>        RCON server port
  [COMMAND]...  By default, rcon-client will read a series of commands from stdin, one per line. You can also
                provide a single command as arguments, which will run the client in "one-shot" mode. In this
                mode, any stdin input will be ignored

Options:
      --password <PASSWORD>            RCON password [env: RCON_PASSWORD=]
      --password-file <PASSWORD_FILE>  Path to a file containing the RCON password. This is the preferred method
                                       for providing the password [env: RCON_PASSWORD_FILE=]
      --no-wait                        Don't wait for a response to the final command before exiting
      --auth-timeout <AUTH_TIMEOUT>    How many seconds to wait for the authentication response [default: 5]
  -h, --help                           Print help
  -V, --version                        Print version

Dependencies

~8–18MB
~256K SLoC