1. Home
  2. Linux
  3. Host a teamspeak server on linux

How To Host A TeamSpeak Server On Linux

Are you a Linux gamer who needs voice chat, but you’re not interested in using cloud solutions like Discord? If you’ve got a home server, consider using a “roll-your-own” solution instead like  hosting a TeamSpeak server.

Create New User

The first step in setting up your TeamSpeak server on Linux is to create a user specifically to run the software safely. Open up a terminal window and use the sudo command to gain a root shell. Gaining root will make it easier to interact with the server and execute many different root commands.

sudo -s

Now that we have root access, we’ll use the adduser command to make a new user. Note that we’ll be using –disabled-login, as the new user shouldn’t ever be able to log in to anything.

adduser --disabled-login teamspeak

usermod -a -G teamspeak teamspeak

There’s no need to add a password to the user, and the system should take care of everything. From here, we can move on to downloading the server software.

Install TeamSpeak Server

TeamSpeak’s server software is proprietary, so no mainstream Linux distributions out there can legally package it and make it easily installable. As a result, users must go out and download it manually. Go over to the official website, and choose the correct version for your CPU. Officially, TeamSpeak supports 32-bit as well as 64-bit. Download it, transfer the file to your server using FTP, Samba, etc. If you don’t feel like moving the software via one of these methods, consider using wget to download it directly.

To wget the latest version of TeamSpeak server, go to the release folder, right-click on the newest version, click “copy link location” and then do the following:

wget https://dl.4players.de/ts/releases/3.1.1/teamspeak3-server_linux_amd64-3.1.1.tar.bz2

or

wget https://dl.4players.de/ts/releases/3.1.1/teamspeak3-server_linux_x86-3.1.1.tar.bz2

Using the tar command, extract the contents of the TeamSpeak server software.

tar -xvf teamspeak3-server_linux_*.tar.bz2

rm *.tar.bz2

Use the chown command to give full permissions to the new user created earlier. Changing ownership of the folder is essential as the Teamspeak user needs to be able to use it without any errors correctly.

Note: For security reasons, never run the TS3 server as root.

mv teamspeak3-server_linux_* /usr/local/teamspeak

chown -R teamspeak:teamspeak /usr/local/teamspeak

cd /usr/local/teamspeak

Using touch, create a file that lets the server software know you’ve accepted the terms and conditions.

touch .ts3server_license_accepted

Next, create a custom systemd service file for TeamSpeak.

cd /etc/systemd/system

echo '' > teamspeak3.service

nano teamspeak3.service

Paste the code below into the Nano text editor, and save it with Ctrl + O.

[Unit]
Description=TeamSpeak 3 Server
After=network.target

[Service]
WorkingDirectory=/usr/local/teamspeak/
User=teamspeak
Group=teamspeak
Type=forking
ExecStart=/usr/local/teamspeak/ts3server_startscript.sh start inifile=ts3server.ini
ExecStop=/usr/local/teamspeak/ts3server_startscript.sh stop
PIDFile=/usr/local/teamspeak/ts3server.pid
RestartSec=15
Restart=always

[Install]
WantedBy=multi-user.target

Start and enable the new teamspeak3.service file with the systemd init tool commands:

systemctl enable teamspeak3

systemctlstart teamspeak3

Restart the server at any time from systemd with the following command.

systemctl stop teamspeak3

Completely disable the server with:

systemctl disable teamspeak3

Logging In

The hard part of setting up a TeamSpeak3 server is over. Now all that’s left is to get your admin key (aka the privilege token). This token is generated randomly the first time that the server software starts up. To get the token, you’ll need to open up your TeamSpeak3 client and connect to your server. The first time you connect to the server, it should ask you to enter a “privilege key.” If you don’t see a prompt asking you to enter the key, you’ll need to search around the settings on your server and click on this option.

Use this command to automatically find and pipe your TeamSpeak server admin token to a file:

cat /usr/local/teamspeak/logs/* | grep "token"

Copy the string of numbers right after “token=” and put it after echo in the ‘ ‘ marks:

echo 'token string' > /usr/local/teamspeak/admin-token.txt

Echoing the string in this way will keep the token file in a safe place.

Using cat, you’ll be able to view the token text file.

To grant your user admin access, copy and paste the contents of the file into the prompt that appears.

cat /usr/local/teamspeak/admin-token.txt

Keep in mind that for each admin, you may need to generate a new privilege token. Be sure to refer to the TeamSpeak website and manual to learn how to do this.

Uninstall TeamSpeak Server

TeamSpeak is nice software but some users don’t care for all the hassle it can cause. If you’ve tried it out and decided you don’t want a TeamSpeak server anymore, just follow these steps and learn how to fully uninstall the software.

First, use systemd to disable and stop the TeamSpeak service.

sudo systemctl disable teamspeak3 -f

sudo systemctl stop teamspeak3

Next, delete the custom systemd service created in setup.

sudo rm  /etc/systemd/system/teamspeak3.service

After that, delete the software from the server.

sudo rm -rf /usr/local/teamspeak/

Lastly, delete the TeamSpeak group and user.

sudo userdel -r teamspeak

sudo groupdel teamspeak

Running all of these commands should remove all references to TeamSpeak from the server. Sudo should work, but if it doesn’t, consider eliminating sudo from each of the above commands and instead, try getting a root shell (sudo -s) beforehand.

Comments are closed.