Git Product home page Git Product logo

rcon's Introduction

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.

Installation

Packaging status

Homebrew

@Holek has made a homebrew tap for rcon, which you can use like this:

$ brew install Holek/rcon/rcon

Manual Installation

You require libbsd, check, cmake and glib-2.0 to successfully build rcon. You have to install those from your distribution's repository. For example:

  • In Debian you'd do something like this:
$ apt-get install build-essential cmake check libbsd-dev libglib2.0-dev
  • In Fedora you'd do something like this:
$ dnf install @c-development cmake check-devel libbsd-devel glib2-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

Debian package

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 and debhelper packages of course, which contain dpkg-buildpackage, and all the dependencies as they are listed in the manual installation section above.

Documentation

The utility comes with a man page: rcon(1). View it with: man 1 rcon.

Usage

Command Line

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.

Standard Input

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

Security Concerns

Please note that the RCON protocol is not encrypted, meaning that your passwords are transmitted in plain text to the server.

Exit Code

The command exit with 0 on success, and some arbitrary non-zero exit code on failure.

Config file

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

Notable Forks

dad's variant is a fork of rcon that offers an ncurses interface. Perfect for running it in a local or remote shell.

See Also

rcon's People

Contributors

butaford avatar n0la avatar nico-castell avatar tamamcglinn avatar yostinso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rcon's Issues

Unknown CMake command "PKG_GET_VARIABLE"

Hi,
i am trying to compile this rcon tool and i get follwoing error on the cmake step on Debian 8.6:

-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- checking for module 'glib-2.0'
-- found glib-2.0, version 2.42.1
-- Looking for arc4random_uniform
-- Looking for arc4random_uniform - not found
-- checking for module 'bash-completion'
-- found bash-completion, version 2.1
CMake Error at CMakeLists.txt:38 (PKG_GET_VARIABLE):
Unknown CMake command "PKG_GET_VARIABLE".

-- Configuring incomplete, errors occurred!
See also "/home/gs/rcon/build/CMakeFiles/CMakeOutput.log".
See also "/home/gs/rcon/build/CMakeFiles/CMakeError.log".

Windows Support?

Hi,
would also be a Windows version possible?
best regards
FreeFun

Homebrew tap

Hey,

I've created a Homebrew tap for this project to easily install this tool on MacOS.

You can try it out at Holek/homebrew-rcon by running

$ brew install Holek/rcon/rcon

Now you can update the packager status in README.md.

You're welcome to fork it and take it over. :) If you fork it you'll be able to install it with brew install n0la/rcon/rcon

Missing Debhelper for Debian Pkg Build

On Debian 11 Bullseye(x86_64), I followed the instructions to build the Debian package and issued:
sudo apt-get install git build-essential cmake check libbsd-dev libglib2.0-dev dpkg-dev

Then attempted to build with dpkg-buildpackage -b -uc -us
Which returned:

dpkg-buildpackage: info: source package rcon
dpkg-buildpackage: info: source version 0.6
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Florian Stinglmayr <[email protected]>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build .
dpkg-checkbuilddeps: error: Unmet build dependencies: debhelper-compat (= 12)
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)

I then installed the debhelper package and dpkg-buildpackage built successfully. I was able to install the package and rcon appears to be functioning correctly. It seems like maybe the directions should be updated to add that additional package along with dpkg-dev. Otherwise is there a different solution to this issue I should have used instead?

Alpine Linux & Test fails on s390x

Hi, thanks for making rcon.

I needed rcon for a Alpine Linux docker setup, so I decided to packaged rcon for Alpine Linux.
It is now available on edge as the following packages rcon, rcon-doc and rcon-bash-completion for these cpu archs ppc64le, aarch64, armv7, armhf, x86_64 and x86.

It will hopefully get moved to community repository before the release of 3.10.

Unfortunately the test fails on s390x - https://build.alpinelinux.org/buildlogs/build-edge-s390x/testing/rcon/rcon-0.4-r0.log and therefore the package are not available on s390x.

I do not have any s390x hardware available, but I might try to debug the issue with a qemu setup in the near future.

Invalid auth reply, valid password? (valve css)

Sorry, maybe I need to create a separate ticket.
When connecting to CSS:
./rcon -1 -H 172.17.1.66 -p 27015 -P RCONPASS status
an error occurs:
Invalid auth reply, valid password?
When using the configuration file:

[csspub]
hostname = 192.168.0.2
port = 27015
password = RCONPASS
#single_packet = true

./rcon -c /path/to/config/example/rconrc -s csspub status
server answers correctly, no errors

sorry bad eng

Originally posted by @butaford in #16 (comment)

I'm getting an error with the cmake command

My terminal:

root@kali:~/Desktop# git clone https://github.com/n0la/rcon.git
Cloning into 'rcon'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 190 (delta 2), reused 7 (delta 2), pack-reused 173
Receiving objects: 100% (190/190), 50.11 KiB | 528.00 KiB/s, done.
Resolving deltas: 100% (103/103), done.
root@kali:~/Desktop# cd rcon
root@kali:~/Desktop/rcon# mkdir build
root@kali:~/Desktop/rcon# cd build
root@kali:~/Desktop/rcon/build# cmake .. -DCMAKE_INSTALL_PREFIX=/usr
-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
CMake Error at /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:505 (message):
  pkg-config tool not found
Call Stack (most recent call first):
  /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal)
  CMakeLists.txt:6 (PKG_CHECK_MODULES)


-- Looking for open_memstream
-- Looking for open_memstream - found
-- Looking for fmemopen
-- Looking for fmemopen - found
-- Looking for arc4random_uniform
-- Looking for arc4random_uniform - not found
-- Looking for pledge
-- Looking for pledge - not found
CMake Error at /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:505 (message):
  pkg-config tool not found
Call Stack (most recent call first):
  /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal)
  CMakeLists.txt:43 (PKG_CHECK_MODULES)


CMake Error at /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:505 (message):
  pkg-config tool not found
Call Stack (most recent call first):
  /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal)
  tests/CMakeLists.txt:3 (PKG_CHECK_MODULES)


-- Configuring incomplete, errors occurred!
See also "/root/Desktop/rcon/build/CMakeFiles/CMakeOutput.log".
See also "/root/Desktop/rcon/build/CMakeFiles/CMakeError.log".

Trying to run on ubuntu with Xonotic

I'm trying to run this on my Xonotic server under ubuntu 16.04 but nomatter what settings I use I get a

Failed to connect to the given host/service

Is there a certain port that rcon looks for? My game server port is 26000... Any ideas on what to check?

rcon hangs (CoD 1.1)

Hello
I'm trying to connect to a Call of Duty patch 1.1 server.
It is hosted on a AWS VPS (debian 11).
There is no issues joining the server from the game, and use /rcon commands from the console.

After entering a rcon command from the vps, it hangs as you could see on the following screenshot :

rcon hangs

I tried to change a map without success.

Please help me

ValueError: 1936613746 is not a valid Type

When running:

from mcipc.rcon.je import Biome, Client     # For Java Edition servers.
#from mcipc.rcon.be import Client           # For Bedrock Edition servers.
#from mcipc.rcon.ee import Client           # For Education Edition servers.

with Client('127.0.0.1', 25565, passwd='7894') as client:
    seed = client.seed                              # Get the server's seed.
    players = client.list()                         # Get the server's players info.
    mansion = client.locate('mansion')              # Get the next mansion's location.
    badlands = client.locatebiome(Biome.BADLANDS)   # Get the next location of a badlands biome.

print(seed)
print(players)
print(mansion)
print(badlands)

I get:

Traceback (most recent call last):
  File "d:\Coding\Python\MinecraftServerWrapper\test.py", line 13, in <module>
    with Client('127.0.0.1', 25565, passwd='7894') as client:
  File "C:\Users\ilaik\AppData\Roaming\Python\Python39\site-packages\rcon\client.py", line 31, in __enter__
    self.connect(login=True)
  File "C:\Users\ilaik\AppData\Roaming\Python\Python39\site-packages\rcon\client.py", line 56, in connect
    self.login(self.passwd)
  File "C:\Users\ilaik\AppData\Roaming\Python\Python39\site-packages\rcon\source\client.py", line 29, in login
    response = self.communicate(request)
  File "C:\Users\ilaik\AppData\Roaming\Python\Python39\site-packages\rcon\source\client.py", line 19, in communicate
    return self.read()
  File "C:\Users\ilaik\AppData\Roaming\Python\Python39\site-packages\rcon\source\client.py", line 24, in read
    return Packet.read(file)
  File "C:\Users\ilaik\AppData\Roaming\Python\Python39\site-packages\rcon\source\proto.py", line 116, in read
    type_ = Type.read(file)
  File "C:\Users\ilaik\AppData\Roaming\Python\Python39\site-packages\rcon\source\proto.py", line 77, in read
    return cls(LittleEndianSignedInt32.read(file))
  File "C:\Program Files\Python39\lib\enum.py", line 384, in __call__
    return cls.__new__(cls, value)
  File "C:\Program Files\Python39\lib\enum.py", line 702, in __new__
    raise ve_exc
ValueError: 1936613746 is not a valid Type

Just wanted to make sure this isn't a problem in your library and if it is how to fix it.

Invalid auth reply, valid password?

While attempting to use the script to send rcon commands to my ARK servers I get an "Invalid auth reply, valid password?" response. I've triple-checked that the password is correct. Oddly, if I supply the wrong password the script simply hangs with no response at all. Is there a known compatibility issue with ARK servers?

Make Errors

I'm getting the following errors when trying to run make:

∴ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_BASH_COMPLETION=OFF
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'glib-2.0'
--   Found glib-2.0, version 2.50.1
-- Looking for arc4random_uniform
-- Looking for arc4random_uniform - found
-- Looking for pledge
-- Looking for pledge - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tielur/sites/rcon/build

∴ make
Scanning dependencies of target rcon
[ 25%] Building C object CMakeFiles/rcon.dir/main.c.o
/Users/tielur/sites/rcon/main.c:219:11: error: implicit declaration of function
      'open_memstream' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    cmd = open_memstream(&c, &size);
          ^
/Users/tielur/sites/rcon/main.c:219:9: error: incompatible integer to pointer conversion
      assigning to 'FILE *' (aka 'struct __sFILE *') from 'int' [-Werror,-Wint-conversion]
    cmd = open_memstream(&c, &size);
        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
make[2]: *** [CMakeFiles/rcon.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/rcon.dir/all] Error 2
make: *** [all] Error 2

Info:

∴ make -v
GNU Make 3.81

libbsd package on Debian is libbsd-dev

You may want to include that in the readme - took me a short while to find this (made a bit more fun by the fact that there exists a libbsd0 as well).

segfault when sending "exec server.cfg"

Hi,

i tried to sent the command "exec server.cfg" to an Insurgency server. I have configured an .rconrc
config file.

$ rcon -s ins1 exec server.cfg

(process:22411): GLib-CRITICAL **: g_byte_array_remove_range: assertion 'index_ < array->len' failed
Segmentation fault

Same with
rcon -s ins1 "exec server.cfg"
rcon -s ins1 'exec server.cfg'

"-- No package 'libbsd' found" in debian bullseye

terminal says

 -- Checking for module 'libbsd'
--   No package 'libbsd' found
CMake Error at /home/linuxbrew/.linuxbrew/Cellar/cmake/3.20.2/share/cmake/Modules/FindPkgConfig.cmake:556 (message):
  A required package was not found
Call Stack (most recent call first):
  /home/linuxbrew/.linuxbrew/Cellar/cmake/3.20.2/share/cmake/Modules/FindPkgConfig.cmake:778 (_pkg_check_modules_internal)
  CMakeLists.txt:44 (PKG_CHECK_MODULES)


-- Configuring incomplete, errors occurred!
See also "/home/kiven/Downloads/rcon-master/build/CMakeFiles/CMakeOutput.log".
See also "/home/kiven/Downloads/rcon-master/build/CMakeFiles/CMakeError.log".

and CMakeError.log says

Determining if the function pledge exists failed with the following output:
Change Dir: /home/kiven/Downloads/rcon-master/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_42d1c/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_42d1c.dir/build.make C>
gmake[1]: Entering directory '/home/kiven/Downloads/rcon-master/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_42d1c.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pledge -o CMakeFiles/cmTC_42d1c.dir/CheckFunctionExists.c.o -c /home/linuxbrew/.linuxb>
Linking C executable cmTC_42d1c
/home/linuxbrew/.linuxbrew/Cellar/cmake/3.20.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_42d1c.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pledge -rdynamic CMakeFiles/cmTC_42d1c.dir/CheckFunctionExists.c.o -o cmTC_42d1c
/usr/bin/ld: CMakeFiles/cmTC_42d1c.dir/CheckFunctionExists.c.o: in function `main':
CheckFunctionExists.c:(.text+0x10): undefined reference to `pledge'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_42d1c.dir/build.make:99: cmTC_42d1c] Error 1
gmake[1]: Leaving directory '/home/kiven/Downloads/rcon-master/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_42d1c/fast] Error 2

but twice for some reson idk whats going on theres not mutch to mess up i even tried the home brew and that did not work, update/upgrade, and sudo apt-get install -y libbsd-dev still did not work

Build Error

Hi, I'm getting the following error when trying to build your package, is this a known issue and is there a resolution to this?

[root@templates build]# make
Scanning dependencies of target rcon
[  9%] Building C object CMakeFiles/rcon.dir/main.c.o
/root/rcon/main.c: In function ‘debug_dump’:
/root/rcon/main.c:114:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; i < sz; i++) {
     ^
/root/rcon/main.c:114:5: note: use option -std=c99 or -std=gnu99 to compile your code

`single_packet` / `-1` is undocumented, has confusing defaults, can't be turned off for non-config-file usage

I was trying to use this with a Minecraft server (which doesn't support multi-packet and just hangs the connection if you try it), and was having trouble translating between the fully command line rcon -H host -p port -P password usage and the config file rcon -s name usage — the former worked fine, the latter would hang, even with the exact same host/port/password settings.

Dug into the code and discovered the (undocumented) single_packet=true / -1 option. It seems like this defaults to true for command line usage (with no way to turn it off?), yet defaults to false for config file usage.

If setting the default to true is the intent, then it's pretty easy to do that — see wisq@de3685e — but there should probably be an option to turn it off for the command line, and it should be added to the manpage. I could certainly look at adding those and submitting a PR, but I wanted to check whether the "default to single packet mode" approach was indeed the intent going forward.

rcon does not work on Minecraft servers

Hi,

decided to use this thread because it seems not to be fixed. I am also trying to connect a minecraft server (don´t mind the avorion hostname), MC replies with one packet but rcon does not proceed.
Will there be any more patching or should we use another tool for MC?

Regards
Martin

grafik

Originally posted by @martin8883 in #16 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.