You could earn up to $300 by adding new articles!

Get Started Now

Terraria Server with TShock on Linux

Published on: Tue, Mar 31, 2015 at 2:50 pm EST

Terraria is a MMORPG based on mining, building, and fighting. Some people say its a 2D version of Minecraft, but that wouldn't do justice to Terraria's offerings - not by a long shot.

In this guide, I'll show you step by step how to make a Terraria server with TShock on Linux. You could even setup multiple Terraria servers.

Some basic Linux knowledge is recommended. At the very least, you should understand how to use SSH.

By the end of the tutorial, you will be able to invite friends over to join your epic quests.

Prerequisites

This tutorial is based on Ubuntu 14.10, but more recent Ubuntu or Debian flavors will work. For other Linux versions, the package names may differ but most of the steps and configuration will be the same.

We will start off with a new Ubuntu 14.10 server on Vultr.

Terraria uses quite a bit of memory, especially for large worlds. For instance, a Vultr server with 1024MB RAM will only support a small world with a few players.

Security

A clean Ubuntu-based image on Vultr starts with access to basic services. Only NTP and SSH ports are opened. If you want to host other services, then you might want to secure your incoming traffic and move your SSH port to something other than the default port.

This guide doesn't cover all the changes needed to secure your server - there are other guides on Vultr Docs for that. Remember, Terraria uses TCP port 7777 by default.

Basic setup

We'll create a basic user to run the Terraria server, since we don't want to run the server as root. After that, we'll install the necessary packages.

Creating a user

Log in to your server as root and create a new user for your Terraria server. You may receive some error messages about missing locales. Ignore those for now.

adduser terraria

The system will ask for a new UNIX password. Enter a fairly secure random password and remember it (or jot it down).

Now, the system will ask for some user details. You can just press Enter to leave these empty.

When the system asks you to confirm the information ("Is the information correct?"), press Y followed by Enter.

Installing packages

Terraria is a game based on the Microsoft ".NET" framework. The Linux implementation of ".NET" is called "mono". We'll install only the necessary packages to get the game running and some support packages.

apt-get -y install wget unzip screen \
    libmono-corlib4.0-cil libmono-sqlite4.0-cil libmono-system-core4.0-cil libmono-system-net4.0-cil \
    libmono-system-runtime4.0-cil mono-runtime mono-runtime-sgen libmono-corlib4.0-cil \
    libmono-sqlite4.0-cil libmono-system-core4.0-cil libmono-system-net4.0-cil \
    libmono-system-runtime4.0-cil  mono-runtime mono-runtime-sgen libmono-data-tds4.0-cil \
    libmysql6.4-cil libmono-system-runtime-serialization4.0-cil \
    libmono-system-runtime-serialization-formatters-soap4.0-cil libmono-system-data-linq4.0-cil \
    libmono-system-xml-linq4.0-cil libmono-system-xml-serialization4.0-cil libmono-system-xml4.0-cil

Your system is now ready to run Terraria.

Installing TShock

At this point, you need to be logged into your server as user "terraria".

su terraria

Download and unzip a release of TShock. You can check the official TShock website for newer releases. The Terraria server download is included with TShock.

wget -O tshock.zip 'https://github.com/NyxStudios/TShock/releases/download/v4.2.9/tshock_4.2.9.zip'
unzip tshock.zip -d ~/tshock

Starting TShock for the first time

The first time you start TShock, you must join your server to make yourself the administrator. Start the server.

cd ~/tshock
mono TerrariaServer.exe

The gameserver will start and show you the server version. After that, it will ask you what world you would like to start. Since this is a new server, there are no previous worlds. We'll create a new one.

The larger the world, the more memory you'll need. Remember, a basic Vultr server with 1024MB RAM will only support a small world.

  • Press N followed by Enter for a new world.
  • Choose the size that you would like.
  • Type a (short) name for your world, followed by Enter.

The server will now start generating your new world. When it has finished, you'll be back in the main selection menu.

  • Choose your newly generated world by pressing 1, followed by Enter.
  • Enter a port to listen on, or just press Enter to use the default Terraria port 7777.

Your world will be loaded and TShock will show you an authorization code.

TShock Notice: To become SuperAdmin, join the game and type /auth 2044111

This token will display until disabled by verification. (/auth-verify)

Write this code down and start Terraria.

Tip: Use windowed mode in Terraria so that you can switch between your SSH session and the game.

  • Go to Multiplayer -> Join.
  • Select or create a character.
  • Enter the IP of your Vultr server.
  • For the server port, use the default 7777 or the port configured on your server.

Congratulations, you've just entered your new world. Now it's time to authenticate as the administrator.

  • In your game window, press Enter.
  • Type /auth XXXXXXX replacing XXXXXXX with the authentication code displayed when your server was started.

The server will confirm your authentication code and display a message.

You are now superadmin, please do the following to finish your install:
/user add <username> <password> superadmin
Creates: <username> with the password <password> as part of the superadmin
group.
Please use /login <username> <password> to login from now on.
If you understand, please /login <username <password> now, and type
/auth-verify

Note: If the text went away too fast, press Enter to show it again.

The server wants us to create a new admin user so that we can gain admin permissions the next time we join our server.

  • Press Enter in your game window.
  • Type /user add <username> <password> superadmin replacing <username> and <password> with your own username and a new password.
  • Press Enter again and log in using /login username password.
  • If this all works correctly, you can confirm everything with /auth-verify.

Now that the configuration is done. We'll shutdown the server and have it save everything.

First, disconnect your Terraria client from the server.

  • Press Escape.
  • Go to "Settings".
  • Select "Save & Exit".

Now, shutdown the server. This is accomplished in your SSH session by typing "off" in the server console, then pressing Enter.

The initial configuration is now complete.

Running your server

We want the server to keep running, even when we disconnect our SSH session. So we'll use a screen session to do so.

As the "terraria" user, start screen:

screen

Press Enter to close the credits screen. Now, start the TShock server again.

cd ~/tshock
mono TerrariaServer.exe

Load your world.

  • Press 1 followed by Enter to select your world.
  • Enter a port or press Enter to use the default port of 7777.

You are now in the server console, for a list of commands, type "help", then press Enter. You can enter Terraria server commands in this console.

To close your SSH session and keep the server running, use the following key sequence:

  • Press Ctrl + A.
  • Press D.

You won't get any feedback until you press the D key.

After this, your screen will be cleared and you will see output similar to the following.

[detached from 1298.pts-2.vultr]

You can now safely close your SSH session and the server will keep running in the background.

When you reconnect to your server, you can type the following to enter the server console again:

screen -r

Closing notes

There are lots of options and things to change with the TShock server. Please read the documentation for more details. Enjoy!

Want to contribute ?

You could earn up to $300 by adding new articles!

Get started in the SSD Cloud!