Install SteamCMD for a Steam Game Server

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

SteamCMD is a command-line version of the Steam client which works with games that use SteamPipe. This enables you to install and update compatible games through the command line. If you intend to host a Steam title on your own game server, installing SteamCMD is a prerequisite.

This guide is intended to get you quickly up and running with SteamCMD on your Linode. See Valve’s SteamCMD wiki page for more information and advanced setups.

Note
This guide is written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, you can check our Users and Groups guide.

Before You Begin

  1. If you have not already done so, create a Linode account and Compute Instance. See our Getting Started with Linode and Creating a Compute Instance guides.

  2. Install the screen utility, which will be used later when running SteamCMD. For more information about how screen works, review the rest of our Using GNU Screen to Manage Persistent Terminal Sessions guide.

Secure Your Game Server

Game servers and clients are an especially ripe target for attack. Use our Setting Up and Securing a Compute Instance guide to:

  1. Add a limited Linux user to your server. Make the username steam to coincide with the rest of Linode’s Steam guides, as well as Valve’s official documentation. Be sure to give the steam user sudo privileges.

  2. Harden SSH access.

  3. Remove unused network-facing services.

  4. If you are using iptables (which is set in Linode’s Ubuntu and Debian images by default), follow the Configure your Firewall Using IPTables section.

  5. If instead you are using firewalld (as in Linode’s CentOS 7 and Fedora images), follow the Configure your Firewall Using FirewallD section.

Configure your Firewall Using IPTables

  1. Create two files named v4 and v6 in your home directory to record your IPv4 and IPv6 firewall rules:

    File: ~/v4
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    
    *filter
    
    # Allow all loopback (lo0) traffic and reject traffic
    # to localhost that does not originate from lo0.
    -A INPUT -i lo -j ACCEPT
    -A INPUT ! -i lo -s 127.0.0.0/8 -j REJECT
    
    # Allow ping.
    -A INPUT -p icmp -m state --state NEW --icmp-type 8 -j ACCEPT
    
    # Allow SSH connections.
    -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
    
    # Allow the Steam client.
    -A INPUT -p udp -m udp --dport 27000:27030 -j ACCEPT
    -A INPUT -p udp -m udp --dport 4380 -j ACCEPT
    
    # Allow inbound traffic from established connections.
    # This includes ICMP error returns.
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    
    # Log what was incoming but denied (optional but useful).
    -A INPUT -m limit --limit 3/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7
    -A FORWARD -m limit --limit 3/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7
    
    # Reject all other inbound.
    -A INPUT -j REJECT
    -A FORWARD -j REJECT
    
    COMMIT
    File: v6
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    *filter
    
    # Allow all loopback (lo0) traffic and reject traffic
    # to localhost that does not originate from lo0.
    -A INPUT -i lo -j ACCEPT
    -A INPUT ! -i lo -s ::1/128 -j REJECT
    
    # Allow ICMP.
    -A INPUT -p icmpv6 -j ACCEPT
    
    # Allow inbound traffic from established connections.
    -A INPUT -m state --state ESTABLISHED -j ACCEPT
    
    # Reject all other inbound.
    -A INPUT -j REJECT
    -A FORWARD -j REJECT
    
    COMMIT
    Note

    Some Steam games require a few additional rules which can be found in our Steam game guides. Steam can also use multiple port ranges for various purposes, but they should only be allowed if your game(s) make use of those services. See this Steam Support page for more information.

    Steam currently supports multiplayer play over IPv4 only, so a Steam server only needs basic IPv6 firewall rules, shown below.

  2. Import the rulesets into your firewall to activate them:

    sudo iptables-restore < ~/v4
    sudo ip6tables-restore < ~/v6
    
  3. Install iptables-persistent. If you don’t install this software, your firewall rules will not persist through reboots of your Linode.

  4. If iptables-persistent was already installed, reconfigure the package so that it recognizes your new rulesets:

    sudo dpkg-reconfigure iptables-persistent
    
  5. Confirm that your firewall rules are active:

    sudo iptables -vL
    

    The output should look similar to:

    Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
    pkts bytes target     prot opt in     out     source               destination
        0     0 ACCEPT     all  --  lo     any     anywhere             anywhere
        0     0 REJECT     all  --  !lo    any     localhost/8          anywhere             reject-with icmp-port-unreachable
        0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             state NEW icmp echo-request
        0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             state NEW tcp dpt:ssh
        0     0 ACCEPT     udp  --  any    any     anywhere             anywhere             udp dpts:27000:27030
        0     0 ACCEPT     udp  --  any    any     anywhere             anywhere             udp dpt:4380
        0     0 ACCEPT     all  --  any    any     anywhere             anywhere             state RELATED,ESTABLISHED
        0     0 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 LOG level debug prefix "iptables_INPUT_denied: "
        0     0 REJECT     all  --  any    any     anywhere             anywhere             reject-with icmp-port-unreachable
    
    Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
    pkts bytes target     prot opt in     out     source               destination
        0     0 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 LOG level debug prefix "iptables_FORWARD_denied: "
        0     0 REJECT     all  --  any    any     anywhere             anywhere             reject-with icmp-port-unreachable
    
    Chain OUTPUT (policy ACCEPT 60 packets, 8304 bytes)
    pkts bytes target     prot opt in     out     source               destination
    
  6. If you ever import new rules into your firewall in the future, be sure to reconfigure iptables-persistent again afterward:

    sudo dpkg-reconfigure iptables-persistent
    

Configure your Firewall Using FirewallD

  1. Set up your ruleset:

    sudo firewall-cmd --zone="public" --add-service=ssh --permanent
    sudo firewall-cmd --zone="public" --add-forward-port=port=27000-27030:proto=udp:toport=1025-65355 --permanent
    sudo firewall-cmd --zone="public" --add-forward-port=port=4380:proto=udp:toport=1025-65355 --permanent
    sudo firewall-cmd --reload
    
  2. Switch on firewalld and verify your ruleset:

    sudo systemctl start firewalld
    sudo systemctl enable firewalld
    sudo firewall-cmd --zone="public" --list-all
    

Install SteamCMD

SteamCMD can be installed via your distribution’s package manager, or through a manual method.

Installing via the package manager allows you to more easily download updates and security patches, so we strongly recommend using this method if your distribution includes the SteamCMD package. The package is available for Ubuntu and Debian deployments.

  • Ubuntu 20.04

    1. Add the multiverse repository and the i386 architecture:

       sudo add-apt-repository multiverse
       sudo dpkg --add-architecture i386
      
    2. Update the repository to make sure new packages can be installed:

       sudo apt update
      
    3. Install the 32 bit libraries that steamcmd requires:

       sudo apt install lib32gcc1 lib32stdc++6 libc6-i386 libcurl4-gnutls-dev:i386 libsdl2-2.0-0:i386
      
    4. Install the steamcmd package:

      sudo apt-get install steamcmd
      
      Note
      In the window that appears, you may need to enter the keys shift + tab to select the ok option.
    5. Create a symlink to the steamcmd executable in a convenient place, such as your home directory:

      cd ~ ln -s /usr/games/steamcmd steamcmd

  • Debian

    1. Add the non-free area to the repositories in your sources list, because the steamcmd package is only available from this area. To do so, edit your /etc/apt/sources.list file and include non-free at the end of each deb and deb-src line, as in this snippet:

      File: /etc/apt/sources.list
      1
      2
      3
      
      deb http://mirrors.linode.com/debian stretch main non-free
      deb-src http://mirrors.linode.com/debian stretch main non-free
      ...
    2. Add the i386 architecture, update your package list, and install steamcmd:

      sudo dpkg --add-architecture i386
      sudo apt update
      sudo apt-get install steamcmd
      
      Note
      In the window that appears following the command to install steamCMD, you may need to enter the keys shift + tab to select the ok option.
    3. Create a symlink to the steamcmd executable in a convenient place, such as your home directory:

      cd ~
      ln -s /usr/games/steamcmd steamcmd
      

Install Manually

If your package manager does not include the steamcmd package, install it manually:

  1. Newly created Linodes use 64-bit Linux operating systems. Since Steam is compiled for i386, install the appropriate libraries. For CentOS, also install wget.

    • CentOS 7, Fedora

      sudo yum install glibc.i686 libstdc++.i686 wget
      
    • Debian, Ubuntu

      sudo apt-get install lib32gcc1
      
    Note
    Running dpkg --add-architecture i386 is not necessary at this point. Our Steam game guides add multiarch support only when a game requires it.
  2. Create the directory for SteamCMD and change to it:

    mkdir ~/Steam && cd ~/Steam
    
  3. Download the SteamCMD tarball:

    wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
    
  4. Extract the installation and runtime files:

    tar -xvzf steamcmd_linux.tar.gz
    
Note

When running a Steam game, you may encounter the following error:

/home/steam/.steam/sdk32/libsteam.so: cannot open shared object file: No such file or directory

The game server will still operate despite this error, and it should be something fixed in a later release of SteamCMD. The temporary fix is to create the directory and symlink to libsteam.so.

mkdir -p ~/.steam/sdk32/
ln -s ~/Steam/linux32/steamclient.so ~/.steam/sdk32/steamclient.so

Run SteamCMD

  1. Run the executable in a screen session:

    If you have installed SteamCMD from repositories:

    screen ~/.steam/steamcmd/steamcmd.sh
    

    If you have installed SteamCMD manually:

    screen ~/Steam/steamcmd.sh
    

    That will return an output similar to below and leave you at the Steam> prompt:

    Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
    [  0%] Checking for available updates...
    [----] Downloading update (0 of 7,013 KB)...
    [  0%] Downloading update (1,300 of 7,013 KB)...
    [ 18%] Downloading update (3,412 of 7,013 KB)...
    [ 48%] Downloading update (5,131 of 7,013 KB)...
    [ 73%] Downloading update (6,397 of 7,013 KB)...
    [ 91%] Downloading update (7,013 of 7,013 KB)...
    [100%] Download complete.
    [----] Installing update...
    [----] Extracting package...
            . . .
    [----] Cleaning up...
    [----] Update complete, launching Steam...
    Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
    [  0%] Checking for available updates...
    [----] Verifying installation...
    Steam Console Client (c) Valve Corporation
    -- type 'quit' to exit --
    Loading Steam API...OK.
    
    Steam>
    
  2. Most Steam game servers allow anonymous logins. You can verify this for your title with Valve’s list of dedicated Linux servers.

    To log in anonymously:

    login anonymous
    

    To log in with your Steam username:

    login example_user
    
    Important
    Some versions of the Steam CLI do not obfuscate passwords. If you’re signing in with your Steam account, be aware of your local screen’s security.

How Do I Update My SteamCMD Game Server?

To update your SteamCMD server, follow these steps:

  1. Run SteamCMD if it is not already running: steamcmd, screen ~/.steam/steamcmd.sh, or screen ~/.steam/steamcmd/steamcmd.sh.
  2. Login anonymously or with your Steam account (depending on the game server): login anonymous or login $username, replacing $username with your Steam username.
  3. Update the app: app_update $app-id, replacing $app-id with the app number/id of the game you wish to update.

Exit SteamCMD

Detach from the Screen Session

To exit the screen session which contains the Steam process without disrupting the Steam process, enter Control+A followed by Control+D on your keyboard. You can later return to the screen session by entering: screen -r

For more information on managing your screen sessions, review our Using GNU Screen to Manage Persistent Terminal Sessions guide.

Stop SteamCMD

To stop the Steam process and remove your screen session, enter quit at the Steam> command prompt, or enter Control+C on your keyboard.

Understanding SteamCMD Error Codes For A Steam Game Server

You may encounter an error when installing or using SteamCMD. Some of these errors may be difficult to understand and overcome. The following list details a few of these error codes and how to resolve them. Additional errors can be found under the Known Issues section of the SteamCMD wiki page.

  • Error! App '232130' state is 0x202 after update job - This error code means that disk space is low. 0x202 is the code that corresponds to the disk running out of space. The associated SteamCMD error output/logs might be similar to the following:

      Filesystem:      /lin/sev2
      Total:           6.1G
      Used:            3.1G
      Available:       2.8G
      LinuxGSM Total:  68M
      Serverfiles:     40K
    

    If you are trying to install a game that’s larger than the Available disk space, you are going to see this error. Review your disk usage by running df -h and examine your Linode’s disk and storage through the Cloud Manager. To overcome this error, you’ll need to either remove files on your disk, resize your disk, or resize your Linode to a larger plan.

  • ERROR! Failed to install app X (No subscription) - This error code means that no authorized accounts on your SteamCMD owns the game. Verify the account on which you purchased the game and make sure that you are logged in using that account.

  • Error! State is 0x402 after update job - Error code 0x402 could mean that either the update servers are down or you have an internet connectivity issue. Verify that your Linode has network connectivity by following the Troubleshooting Basic Connection Issues guide.

  • Error! State is 0x602 after update job - This code 0x602 implies a network error. When this error shows up, you most probably need to update your system and your network is preventing your SteamCMD from updating.

  • Error! App '237410' state is 0x10502 after update job - The code 0x10502 points to your application’s AppState, stored in the app manifest of your installed steam app. Under this code, take a look at the StateReconfiguring, StateUpdateStarted, StateUpdateRunningStarted and StateUpdateRequired codes. These status codes point towards a file download in process or a downloaded file is in the process of being installed. Based on what the issue is you can take the next step to resolve it.

Next Steps

You’re ready to install your first Steam game server. From here, certain games may need a few more i386 libraries or firewall rules, and most will need their configuration settings to be modified. The game server should allow easy administrative access with as little interruption to players as possible. Its software should frequently be updated, and players’ progress should be saved when the server is properly shut down.

Our game server guides cover these requirements for specific games and contain various Steam tutorials which will pick you up exactly where this page leaves off.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.