Running a Server

Cheap KF2 Server on a VPS: LinuxGSM, Web Admin and Hardening

This page paraphrases an English community guide (by a French author) on running your own Killing Floor 2 dedicated server on a cheap VPS using LinuxGSM. Other hosting guides: KF2 dedicated server with SteamCMD and systemd user service on Linux.

Step 1: choose a host and log in

Aim for the cheapest server that meets the requirements. Suggested providers include Serverspace, Vultr, Scaleway and OVH; switch the site language to see prices for your country. Serverspace and Scaleway let you stop the server when not in use so you do not pay for idle months. Choose a data center near you (check even the city, since a neighboring country can be closer than another city of your own) for lower latency.

Minimum configuration:

  • 1 CPU core
  • 1 GB RAM
  • 25 GB disk, SSD ideally (a 20 GB disk is not enough to install KF2)
  • IPv4 only, no IPv6
  • Unlimited traffic (optional)
  • Ubuntu Server 18.04

While you wait for the server, install PuTTY. When the server is ready you receive the IPv4 address and root credentials by email or in the control panel. In PuTTY enter the IPv4 address, port 22, connection type SSH, save a name, open it and accept the certificate. Log in as root with the provided password.

PuTTY connection settings The PuTTY main page with the server address and SSH port.

Logged in as root A successful root login.

Step 2: install the KF2 server

  1. Update the system: apt-get update && apt-get upgrade -y.
  2. Install SteamCMD from the multiverse repository (it is not in the default list on a 64-bit system):
    • add-apt-repository multiverse
    • dpkg --add-architecture i386
    • apt update
    • apt install lib32gcc1 steamcmd (confirm with y and accept the license using arrow keys, space and enter).
  3. Install the needed packages: apt install mailutils postfix curl wget file tar bzip2 gzip unzip bsdmainutils python util-linux ca-certificates binutils bc jq tmux libstdc++6 lib32stdc++6 netcat.
  4. Create a normal user instead of using root: adduser kf2server, set a strong password, then usermod -aG sudo kf2server and su - kf2server.
  5. Download LinuxGSM: wget -O linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh kf2server.
  6. Install: ./kf2server install. It takes roughly 15 to 20 minutes and about 20 GB; if packages are missing the installer asks for the user password to install them with sudo.
  7. Start and stop once to create the config files: ./kf2server start and ./kf2server stop.

Step 3: configure the server

Install nano if needed (sudo apt install nano) and go to serverfiles/KFGame/Config.

  • KFWeb.ini: in [IpDrv.WebServer] set bEnabled=true and optionally change ListenPort=8080 to another port between 2000 and 9999 to enable the web admin panel.

    KFWeb.ini web admin settings Enabling the web admin in KFWeb.ini.

  • LinuxServer-KFEngine.ini: search with Ctrl+W for bUsedForTakeover and set it to FALSE to disable the server lease (takeover) system, so that another player's search cannot take your server over.

    bUsedForTakeover setting Turning off takeover.

  • LinuxServer-KFGame.ini: under [Engine.AccessControl] set AdminPassword (web admin password) and optionally GamePassword to limit joins to friends. Difficulty can be set later in the web admin.

    Admin and game passwords Setting passwords in KFGame.ini.

Save in nano with Ctrl+X, Y, Enter. Return to the root of your folder (cd .. repeatedly), then ./kf2server start and ./kf2server details. The status should say online. If "WebAdmin enabled" is false, repeat the KFWeb.ini and KFGame.ini edits in serverfiles/KFGame/Config/kf2server and run ./kf2server restart.

Open the link from details (http://<ipv4>:<port>) in a browser, log in with the user Admin and your admin password, and adjust the game settings.

Web admin login page The web admin login page.

To join, start KF2, press F3 for the console and type open <ipv4server>. A game password, if set, is requested automatically.

Step 4: secure the VPS (optional)

  1. Change the root password: su - root, then passwd root.

  2. Change the SSH port and block root login: as root edit nano /etc/ssh/sshd_config. Uncomment the Port line and set a port between 2000 and 9999; search for "Authentication", uncomment the three lines and set PermitRootLogin no. Save, then run /etc/init.d/ssh restart. Remember the new port: port 22 will stop working and root can no longer log in directly. Test by logging in again with the new port as kf2server.

    Changing the SSH port Set the SSH port in sshd_config.

    PermitRootLogin Disallow root login.

  3. Firewall: as root, apt install ufw, then ufw allow <your SSH port> first (a mistake here can lock you out), and the game ports: ufw allow 27015/udp, ufw allow 20560/udp, ufw allow 7777/udp, ufw allow 123/udp and ufw allow <web admin port>/tcp. Remove a wrong rule with ufw delete allow <port>/.... Then run ufw disable and ufw enable and confirm with Y; if you are not kicked out, it worked. Check with ufw status and remove the default "OpenSSH" rule for port 22.

Exit root and test the game server and web admin.

Basic LinuxGSM usage

Run ./kf2server to list all commands. The common ones:

  • start, stop, restart, and console (view the live console; exit with Ctrl+B then D, since Ctrl+C terminates the server).
  • update (checks and applies updates, restarts only if needed), force-update (skip the check) and validate.
  • details (passwords, ports, config files), debug (output to terminal) and logs in /home/kf2server/logs.
  • backup creates a tar.bz2 archive of the server; monitor checks the process and can restart it and send alerts, scheduled with cron.

Settings of LinuxGSM itself are described in its documentation (config files page).

FAQ

What VPS specs does a KF2 server need?
The guide's minimum is 1 CPU core, 1 GB RAM, 25 GB of SSD space (20 GB is not enough to install the server), IPv4 only and Ubuntu Server 18.04.
Which firewall ports are needed?
27015/udp, 20560/udp, 7777/udp, 123/udp and the TCP port of the web admin (8080 by default), plus your custom SSH port.
How do I connect to the server in game?
Open the console menu with F3 in the game and type open followed by the server's IPv4 address.