Get Rewarded! We will reward you with up to €50 credit on your account for every tutorial that you write and we publish!

Setting up Counter-Strike 2 Dedicated Server

profile picture
Author
BakirGracic
Published
2026-01-23
Time to read
11 minutes reading time

About the author- Web Solutions Architect - I'm transforming businesses with constant headaches

Introduction

Counter-Strike 2 allows anyone to host dedicated servers free of charge using Valve's SteamCMD tool. However, hosting from your personal computer introduces network complexity and reliability issues. This tutorial guides you through setting up a production-ready CS2 dedicated server. This is a cost-effective and scalable solution that ensures your server stays online 24/7 with proper networking and security.

By following this guide, you will:

  • Provision a server running Ubuntu 24.04 and protect it with proper firewall rules
  • Install and configure SteamCMD to manage your CS2 server files
  • Generate a Game Server Login Token (GSLT) for public server registration
  • Launch your CS2 server with custom settings and game modes
  • Keep your server running persistently using screen

Prerequisites

To complete this tutorial, you need:

  • A VM (e.g. with Hetzner)
  • Basic familiarity with SSH and command-line interfaces
  • A Steam account (the same one will authenticate your server)
  • 30–60 minutes to complete the full setup

If you're unfamiliar with SSH or Linux basics, consider reviewing a general Linux getting-started guide first.

Step 1 - Set Up Your Infrastructure

Step 1.1 - Create Your Virtual Private Server

Now you'll provision the actual server that will host CS2.

Settings:

Description
Server Type: With Hetzner, a CX33 will be sufficient for 10-32 players.

We need at least 4 vCPU cores, 8GB RAM and 80GB disk space. If your region doesn't have CX33, choose the next closest plan with similar specs
Location: Choose the region closest to your players
Operating System: Ubuntu 24.04
Server Name: "cs2-server" or descriptive name

It is recommended to add an SSH key

Billing Note: Hetzner charges hourly. A 3-day trial costs significantly less than the monthly price. The static IPv4 address is inexpensive and required.

Step 1.2 - Configure a firewall

Firewalls protect your server by controlling which network traffic is allowed. CS2 requires multiple ports for different functions.

Note: Not all ports are strictly required for a private server. Refer to the official Valve CS2 documentation for optional ports based on your use case.

You can either setup a firewall directly on the server via ufw, or create a new Hetzner Firewall and attach it to your Hetzner cloud server.

Option A - ufw

  • Add these rules:

    sudo ufw allow 22/tcp comment 'SSH - Server Management'
    sudo ufw allow 27015/udp comment 'Game Server'
    sudo ufw allow 27015/tcp comment 'RCON & Pings'
    sudo ufw allow 27005/udp comment 'Client Communication'
    sudo ufw allow 27020/udp comment 'SourceTV Demo Recording'
    sudo ufw allow 27036/tcp comment 'Steam Remote Play'
    sudo ufw allow 3478/udp comment 'NAT Traversal'
    sudo ufw allow 4379/udp comment 'Matchmaking'
    sudo ufw allow 4380/udp comment 'Matchmaking'
  • If the firewall isn't enabled yet, enable it now:

    sudo ufw enable
    sudo ufw status

Option B - Hetzner Cloud Firewall

If you have a Hetzner cloud server, you can protect it via a Hetzner Firewall.

  1. In your project, navigate to Firewall and click Create Firewall

  2. Add these inbound rules:

    Purpose Protocol Port
    SSH (Server Management) TCP 22
    Game Server UDP 27015
    RCON & Pings TCP 27015
    Client Communication UDP 27005
    SourceTV Demo Recording UDP 27020
    Steam Remote Play TCP 27036
    NAT Traversal UDP 3478
    Matchmaking UDP 4379
    Matchmaking UDP 4380
  3. Name your Firewall (e.g., "cs2-firewall") and click Create Firewall

  4. Apply the Firewall to the server that you created in the step above.

Step 2 - Install Dependencies and Steam Server Files

Step 2.1 - Connect via SSH

SSH allows you to remotely control your server. Replace YOUR_SERVER_IP with your actual server IP.

ssh root@YOUR_SERVER_IP

If you didn't provide an SSH key, you will be prompted for a password. With Hetzner, the password is sent to you via email. (The password won't display as you type — this is normal for security.)

Step 2.2 - Update the System

Always update your system packages for security and stability.

apt update && apt upgrade -y && apt autoremove -y && reboot

The server will reboot. Wait about 1 minute, then reconnect using the same SSH command above.

Step 2.3 - Create a Dedicated Steam User

Running services as root is a security risk. Create a non-root user specifically for the CS2 server.

adduser steam
usermod -aG sudo steam

This creates the steam user and grants it sudo privileges so it can install packages, configure the firewall, and manage the CS2 service in later steps. If you prefer stricter separation of duties, you can skip adding steam to the sudo group and instead run any sudo commands from your root account. Set a strong password and press Enter to skip optional fields. Then switch to this user:

su - steam

Step 2.4 - Install SteamCMD and Dependencies

SteamCMD is Valve's command-line tool for downloading and managing game server files. This command installs required 32-bit libraries and SteamCMD itself:

sudo apt-get install lib32gcc-s1 -y && \
sudo add-apt-repository multiverse && \
sudo dpkg --add-architecture i386 && \
sudo apt update -y && \
sudo apt install steamcmd -y

Press Enter to accept any prompts. The installation takes 2–3 minutes.

Step 2.5 - Download CS2 Server Files

Create a directory for your server and download the CS2 files using SteamCMD.

mkdir -p ~/cs2-server && cd ~/cs2-server
steamcmd +login anonymous +force_install_dir ~/cs2-server +app_update 730 validate +quit

This downloads approximately 60GB of data. The process takes 10–30 minutes. You should see Success! App '730' fully installed when complete.

Step 2.6 - Authenticate with Steam and Generate Your Game Server Login Token

You need a Steam account to run the server. Valve recommends using a dedicated account:

steamcmd +login YOUR_STEAM_USERNAME

Enter your password and any 2FA code if prompted. Type quit to exit SteamCMD.

Now you need a Game Server Login Token (GSLT). Visit Steam's Game Server Account Management with the same Steam account:

  1. Enter 730 in the "App ID" field
  2. Enter a memo like "CS2 Server - Hetzner"
  3. Click Create
  4. Copy the generated token and save it somewhere safe

Important: Your server won't appear in the public server browser without a valid GSLT. Each server requires its own token.

Step 2.7 - Set Up the Steam SDK

Enable Steam library loading for your user:

mkdir -p ~/.steam/sdk64 && \
ln -s ~/.local/share/Steam/steamcmd/linux64/steamclient.so ~/.steam/sdk64/steamclient.so

If you see "already exists," that's fine—skip this step.

Step 3 - Launch Your CS2 Server

Step 3.1 - Start the Server with Launch Parameters

Navigate to the game directory and launch your server. Replace the placeholders with your actual values:

Replace:

  • <10.0.0.1> with your server's IP address
  • YOUR_SERVER_NAME with your desired server name (e.g., "John's CS2 Server")
  • YOUR_GSLT_TOKEN with the token generated in Step 2.6
cd ~/cs2-server/game && \
./cs2.sh -dedicated -ip <10.0.0.1> -maxplayers 10 -port 27015 \
  +hostname "YOUR_SERVER_NAME" \
  +map de_dust2 \
  +sv_logfile 1 \
  +sv_lan 0 \
  +game_type 0 \
  +game_mode 1 \
  +sv_setsteamaccount "YOUR_GSLT_TOKEN"

Critical: Always use ./cs2.sh, not the binary directly. The script properly configures the Linux environment for required libraries.

Step 3.2 - Understand Launch Parameters

These parameters control your server's behavior:

Parameter Purpose Example
-dedicated Launches as a dedicated server Required
-ip Binds server to specific IP <10.0.0.1>
-maxplayers Maximum player slots (max 64) 10
-port Game port (default 27015) 27015
+hostname Server name in browser "CS2 DM Server"
+map Starting map de_dust2
+sv_logfile Enable logging (1=yes, 0=no) 1
+sv_lan 0=Internet, 1=LAN only 0
+game_type 0=Casual, 1=Competitive 0
+game_mode Game mode variant 1
+sv_setsteamaccount Your GSLT token Your token

Step 3.3 - Verify Server Launch

Once launched, watch the console output for these success indicators:

Loading map "de_dust2"
Server is now accepting players

These lines confirm your server is running and accepting connections.

Step 3.4 - Test Your Connection

In CS2, go to the settings menu and make sure "Enable Developer Console" is set to YES.

Open the console (default: ~ key) and connect to your server:

connect <10.0.0.1>:27015

If your server has a password, you'll be prompted to enter it. Successful connection confirms your server is working.

Step 4 - Advanced Configuration

Step 4.1 - Create a Configuration File

Instead of typing parameters each launch, save settings to a config file:

nano ~/cs2-server/game/csgo/cfg/server.cfg

Add your server settings:

hostname "My CS2 Server"
sv_password "" // Leave empty for no password, or set to your desired password
mp_timelimit 45
mp_roundtime 2
sv_cheats 0
bot_difficulty 1

Before you launch the server for a second time, make sure the first one is no longer blocking the game port:

sudo lsof -i :27015
sudo kill <PID>

Now launch your server with the config:

cd ~/cs2-server/game && \
./cs2.sh -dedicated +exec server.cfg \
  +sv_setsteamaccount "YOUR_GSLT_TOKEN" \
  +map de_dust2

Step 4.2 - Use Different Game Modes

CS2 supports multiple game modes. Adjust your launch command:

Game Mode Command
Competitive +game_alias competitive
Wingman (2v2) +game_alias wingman
Casual +game_alias casual
Deathmatch +game_alias deathmatch
Custom +game_alias custom

Example for competitive:

./cs2.sh -dedicated +game_alias competitive +sv_setsteamaccount "TOKEN"

Step 4.3 - Use Custom or Workshop Maps

To run custom maps, disable VAC (Valve Anti-Cheat):

./cs2.sh -insecure -dedicated \
  +sv_setsteamaccount "YOUR_GSLT_TOKEN" \
  +map "your_custom_map"

Warning: Using -insecure disables anti-cheat. Use this only for private, trusted servers.

Step 5 - Keep Your Server Running Persistently

Step 5.1 - Use Screen for Background Execution

Your server stops when you close your SSH connection. Use screen to keep it running:

sudo apt install screen -y

Start a named screen session:

screen -S cs2-server

Now launch your CS2 server inside this screen session. To detach (leave it running), press Ctrl+A then D.

Step 5.2 - Reattach to Your Running Server

To view your server's console output later:

screen -r cs2-server

To detach again, press Ctrl+A then D.

Step 5.3 - Check Server Status

List all screen sessions:

screen -ls

You'll see your cs2-server session listed. If the server crashes, you can reattach and restart it.

Conclusion

You now have a fully operational CS2 dedicated server running 24/7. Your Hetzner cloud server is:

  • Scalable: Easily upgrade your CX33 to larger instance types as your player base grows
  • Cost-effective: Pay only for the resources you use with hourly billing
  • Secure: Protected by Hetzner's Firewall
  • Persistent: Running continuously via screen

Next Steps:

  • Customize your server: Add more advanced settings to server.cfg
  • Monitor performance: Use Hetzner's console graphs to track CPU, memory, and network usage
  • Automate updates: Create a cron job to periodically update CS2 files via SteamCMD
  • Set up backups: Take snapshots of your server configuration for disaster recovery
  • Scale up: If you reach player limits, resize your server to a more powerful plan

For official CS2 server configuration details, always refer to the official Valve CS2 Dedicated Servers documentation.

License: MIT
Want to contribute?

Get Rewarded: Get up to €50 in credit! Be a part of the community and contribute. Do it for the money. Do it for the bragging rights. And do it to teach others!

Report Issue

Discover

#Hetzner4gamers

Take your gaming experience to the next level! Discover which Hetzner server is best for your gaming world.

Get started
Want to contribute?

Get Rewarded: Get up to €50 credit on your account for every tutorial you write and we publish!

Find out more