rcon is a command line application that can be used as a Source RCON client. It will send commands to the given server, and print the reply to stdout.
@Holek has made a homebrew tap for rcon, which you can use like this:
$ brew install Holek/rcon/rcon
You require libbsd
, check
, cmake
and glib-2.0
to successfully build rcon. You have to install those from your distribution's
repository. If you wish to compile the ncurses based version, you will also need
the ncurses. For example:
- In Debian you'd do something like this:
$ apt-get install build-essential cmake check libbsd-dev libglib2.0-dev [libncurses5-dev]
- In Fedora you'd do something like this:
$ dnf install @c-development cmake check-devel libbsd-devel glib2-devel [ncurses-devel]
Then build the project:
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr
$ make
$ sudo make install
A bash-completion
script is available, but not installed by default.
If you use bash completion simply specify INSTALL_BASH_COMPLETION=ON
on
the cmake command line:
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_BASH_COMPLETION=ON
If you prefer to build a Ubuntu/Debian package out of the source code: You can! Just run the following command in the source code:
$ dpkg-buildpackage -b -uc -us
You will need the dpkg-dev
package of course, which contains
dpkg-buildpackage
, and all the dependencies as they are listed in the manual
installation section above.
The utility comes with a man page: rcon(1)
. View it with:
man 1 rcon
.
The command can be called from the command line directly, like so:
$ rcon -H somehost -p someport -P somepass status
rcon automatically concats all your arguments together into one command:
$ rcon -H somehost -p someport -P somepass sm plugins list
This sends the command "sm plugins list" to the server.
If you wish to send more than one command to the server, don't specify one on the command line. Instead give rcon a list of commands through standard input:
$ rcon -H somehost -p someport -P somepass <<EOS
status
sm plugins list
# This might be long!
cvarlist
EOS
In this mode lines starting with #
are ignored. This allows rcon to be
used as a script interpreter. Just pass it the script file through stdin:
$ cat somescript.txt
# This is a comment
status
# and this too!
sm plugins list
cvarlist
And execute your script like this:
$ rcon -H somehost -p someport -P somepass < somescript.txt
# Or:
$ cat somescript.txt | rcon -H somehost -p someport -P somepass
The command exit with 0 on success, and some arbitrary non-zero exit code on failure.
You can also store your server credentials in a configuration file. The default
location for this file is $HOME/.rconrc
. You can specify an alternate
configuration file through the -c
option. Entries from this configuration
file are referenced through the -s
option.
Here is an example configuration file:
[somehost]
hostname = 174.53.163.41
port = 27045
password = somepass
# remove the following line if the server
# is not minecraft, or set it to 'false'
minecraft = true
Now you can do:
$ rcon -s somehost status
dad's variant is a fork of rcon that offers an ncurses interface. Perfect for running it in a local or remote shell.
The rcom protocol transmits everything (including your rcon password) un-encrypted. Thus, anyone with access to your internet connection could conceivably capture your password and/or monitor your rcon traffic. If this is a concern to you, you may wish to tunnel your rcon connection through ssh or some other secure VPN running on your server. For example, the following command will connect to the remote server using ssh and then run rcon on the remote server (rcon will connect to the server locally without exiting the server's firewall).
ssh -t someuser@174.53.163.41 rcon --host 174.53.163.41 --port 27045 --password somepass