Server Setup

From GT New Horizons
Jump to navigation Jump to search


THIS GUIDE IS NOT COMPLETE YET (3/1/2019)


LINUX SETUP on Linode (Console Only)

RAM: 4GB

CPU: 2 vCPU

SSD: 80GB

Monthly Cost: $20

This section of the guide will focus on setting up a GTNH server using Debian Linux hosting on Linode. These steps can be applied to other distributions and hosting as well but keep in mind these are specifically written for Debian Linux using Linode as a host. If you're unsure how to adapt these steps to your distribution preference or hosting preference then I'd suggest following this guide explicitly.

Some of the tools we will be using in this section of the guide are:

Signing Up For Linode

The first thing we need to do is setup a hosting account for your server.

  1. Head over to https://www.linode.com/signup and fill in the details to create your account.
  2. Once you've filled out the username, e-mail and password you will be sent a verification e-mail to confirm your account.
  3. Clicking the link in the e-mail will take you to Linode to setup your billing details so go ahead and fill those out.
  4. If you're not automatically logged in you can now login to Linode and you will be greeted with the following dashboard:
    Linode Dashboard.png

SECURITY RECOMMENDATION

Once you're logged into your dashboard it is STRONGLY encouraged to setup Multi-Factor Authentication (MFA). This will help protect your personal details, billing information and of course console access to your server.

  1. Click on your username in the upper right hand corner of the Linode Dashboard and select "My Profile":
    Profile.png

  2. On your profile you want to select the "Password & Authentication" tab at the top and then toggle Two-Factor Authentication (TFA) on. I suggest using Google Authenticator for this as I know it works and it is pretty easy to setup, however, any application you have on your device will work similarly:
    MFA Setup Screen.png

  3. Go ahead and confirm your token and complete the setup of MFA. Again this is HIGHLY RECOMMENDED.

Creating Your Linode Instance

Once you have your account setup, you're logged in and IDEALLY MFA IS SETUP. We can go ahead and create the server instance.

  1. Go ahead and click on "Linodes" on the left side of the screen.
  2. Next click on "Add New Linode.
    Add Linode.png

  3. You want to select the following options:
    1. Debian (Debian 9) - Usually selected as default.
    2. When it comes to the region I recommend picking a location that is geographically near you and/or your player base. For me that happens to be US:Texas. Linode offers locations in Europe and Asia as well.
    3. We want the "Standard" tab under plans and at least the "Linode 4GB" plan.
    4. Next enter a STRONG root password. I'd even suggest using a password generator if you have one available.
    5. You can also label your Linode if you wish. This doesn't affect the system itself but just shows you the name in your Linode list.
      Linode Step 1n.png
      Linode Step 2.png

  4. You can optionally add a backup for $5/mo if you want. (In my experience issues I have with data loss are related to world corruption and not lost data with this service and I've used Linode for 5 years on various systems with no issues - we will be doing world backups using MSCS though to help protect your progress).
  5. At this point you can go ahead and create the instance on the right side:
    Linode Confirmation.png

This will take you back to your dashboard showing the new instance as provisioning.

Linode Configuration

From your Linode Dashboard find your server (it is likely the only one listed) and click the "Launch Console" button.

Launch Console.png

From here on out we will be more or less living in the command line. The first thing we need to take care of is setting up some security and giving yourself a normal user account as well as remote access.

Add Linode User and Configuring UFW (Firewall)

Go ahead and type in the username: root and whatever you set your root password to during the creation of the Linode above.

  1. Add a user for yourself that isn't privileged. Once we have remote access we will only access the server over SSH and only using your normal user account:
    adduser shawn
    
  2. Add your user to the sudo group. This allows you to run commands with elevated privilege:
    adduser shawn sudo
    

Setup and Configure UFW (Uncomplicated Firewall)

  1. At this point it is a good idea to check for system updates:
    apt update && apt upgrade
    
  2. Next let's install a software firewall. We will use ufw (Uncomplicated Firewall):
    apt install ufw
    
  3. Here is the tricky bit. You will need your IP address. MOST ISP (Internet Service Providers) don't give you static ones. Some will give you a static if your request it or pay for it, however, most ISPs will generally always give you the same address due to the nature of always-on internet. You can find your IP address by going to Google and typing in: "what is my ip" and it will display your public IP address. Let Me Google That For You (LMGTFY) We will need this to setup a firewall rule to only allow connections to your server from your IP address. This may just be a game server but security is ALWAYS important. We don't want people trying to login to your server shell and perhaps maybe not even your Minecraft server. Once you add the following rule your server will reject any connections not originating from your IP. SSH (Secure SHell) utilizes port 22. Use the following command and replace the 999 parts with your IP:
    ufw allow from 999.999.999.999 to any port 22
    
    Next we need to enable the firewall with this command (this will ask you to confirm):
    ufw enable
    
    You can then verify the firewall is setup with the correct information by this command
    ufw status verbose
    

Note: You can ALWAYS get to your console by logging into your Linode Dashboard (this is why I highly recommend setting up MFA above - I cannot recommend this enough).

Remote Access via SSH

  1. Now that we have the firewall rule to allow you to SSH to the server from your computer and it is time to ditch the root access console. So let's get an SSH tool and test it before we logout of the console. Two I recommend are:
    1. MobaXterm https://mobaxterm.mobatek.net/download.html
    2. Putty https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
  2. Let's use MobaXterm (this will make transferring files over to the server easier) in this example. You will need the IP of your server which you can again see in the Linode Dashboard in the same place you Launch Console from. (See above. I have my IPs blocked out but that is where they are). Use this IP to setup a SSH connection in MobaXterm. Download and install MobaXterm from the link above.
  3. Now let's create our connection. From the file menu go: Session --> New Session.
  4. On the popup window choose SSH.
  5. Type your Linode Server IP in the "Remote Host" field.
  6. Click OK.
  7. At this point if MobaXterm doesn't connect you to your host you can double click the IP address in the left hand window pane.
  8. If you did the firewall setup correctly you should now be able to login to your server.

Setup MSCS (Minecraft Server Control Script)

Feel free to browse the wonderful documentation over at mscs on GitHub https://github.com/MinecraftServerControl/mscs I'm going to walk you through how I set this up.

Prerequisites

First we need to make sure we have all of the software required for mscs and Minecraft as well. To install these prerequisites run this command:

sudo apt install default-jre perl libjson-perl libwww-perl liblwp-protocol-https-perl python make wget rdiff-backup rsync socat git

MSCS Install

Let's make sure you're in your user home folder by typing the following command:

Next let's get our copy of mscs:

git clone https://github.com/MinecraftServerControl/mscs.git

Now we need to navigate into the mscs directory:

cd mscs

Next let's install mscs:

sudo make install

If you want or need to update MSCS you can follow that section on their documentation on GitHub. Maintenance is beyond the scope of this article.

Creating Your Minecraft World

We're going to go ahead and create the Minecraft world now. To do this we use the following command (you can put in your world name in place of gtnh - I'd advise against using spaces):

sudo mscs create gtnh 25565

Next we need to make sure to allow this in the firewall. The first line will allow connections to the Minecraft portion of the server from everywhere. The second line will allow connections from specific IPs. Personally I use the first one but then limit players that are allowed to connect to my server with the Minecraft whitelist. It is a good balance between security and accessibility. Otherwise if your friend's IP changes or your IP changes you will have to edit your firewall:

sudo ufw allow 25565

Now let's start the world to download the necessary Minecraft files:

sudo mscs start gtnh

This will error out because we will need to edit the EULA.txt. This may take a while. You can check the status of your server by:

sudo mscs status

If you want to see the console output and the EULA error you can use the following command (CTRL+D will exit the Minecraft console and take you back to your Linux shell):

sudo mscs console gtnh

Let's go ahead and accept the EULA:

sudo nano /opt/mscs/worlds/gtnh/eula.txt

This editor is very simple. Just arrow key your way down to where it says "eula=false" and change that to "eula=true". To EXIT and SAVE we do: CTRL+X, it will ask if we want to save changes so we hit Y for yes and then enter to confirm. After that we will be back to our Linux shell.

Note: this will install a vanilla Minecraft instance into which we will install the GTNH modpack.