Server Setup (Linux)

From GT New Horizons

This guide is written specifically for running a remote server on Linux with Java 17+. For general information and other platforms, see Server Setup.

  • Latest Revision: May 2024, GTNH version 2.6.0.

Introduction

The instructions below are specific for Hetzner but may help with generic Linux installs. Every step except the "Sign up for Hetzner Cloud and Purchase a server." will be pretty similar.

The steps are as follows:

  1. Install PuTTY and generate a Keypair
  2. Sign up for Hetzner Cloud and Purchase a server.
  3. Connecting to the server.
  4. Set up a GTNH server.
  5. (Optional) Configure the pack / mods.
  6. Run the server.

Install PuTTY and generate Keypair

Before we get started, you will have to understand what a keypair is. A keypair is a combination of a public key and a private key. The private key is like your password. Your public key is like the lock, that your private key opens. Your server will contain your public key, and your computer will contain your private key that you use to connect to said server.

Don't share your private key with anyone !!!!!

Go to the PuTTY download page and download & install the version that's relevant to you (probably "MSI (‘Windows Installer’) 64-bit x86").

Launch PuTTYgen.

In the bottom, change the "Number of bits in generated key" to 4096. Don't change anything else.

Click "Generate" (next to Actions -> Generate a public/private key pair).

Move your mouse over the blank area to create randomness for your key.

Change the key comment, this will be used to identify your keypair. This guide advises "GTNH-keypair".

Enter a passphrase for your private key (under Key passphrase / Confirm passphrase). This will be used to "unlock" your private key so it can be used.

Once you have filled in all the key fields, click "Save private key" and save it to a secure location you can find back. Also copy the text at the top ("Public key for pasting into OpenSSH authorized_keys file: ") and save it somewhere secure, since this is the format Hetzner expects, unlike the "save public key" button. This text will be "ssh-rsa [a bunch of text] [your key comment]". If you have saved these two things, you can close the window.


Signup and Purchase Server

Go to the Hetzner Signup page and create an account.

After logging in, click "New project". Give your project a name. Click "Add Server".

Pick the region that is closest to you. Select "Ubuntu 24.04" (the default).

Select "Dedicated vCPU". Select the server you want (As of writing this guide, I use the CCX23 for €29,03 per month).

Leave the networking settings to their default (IPv4, IPv6).

For "SSH Keys", click "Add key" and paste the PUBLIC (!) key that you saved. Click "Set as default key" and click "Add SSH key".

Leave Volumes, Firewall, Backups, Placement groups, Labels, Cloud Config all the same / empty / default.

Under Name, enter the name you want to give your server, this guide advises "GTNH-Server".

It should look something like this. If it does, click "buy now".

Settings for the Hetzner Cloud instance

Click "Create and buy now".

In this screen, you will get an overview, including "Public IP". This is what you will use to connect to your server, both for SSH and for Minecraft. Save this somewhere.

Connecting to the server

This will connect to the (ubuntu) server you have created using the SSH protocol. For the purpose of this tutorial, this will be referred to as Connecting or SSH'ing.

Open PuTTY. Open the ssh field on the left, and click (do not open) "auth". If you are on an older version of putty, under "authentication parameters -> Private key file for authentitcation:", click Browse to select your private key file. If you are on newer versions, expand "auth", then click "Credentials". Here, under "authentication parameters -> Private key file for authentitcation:", click Browse to select your private key file. Select the private key file you just saved. (the .ppk file).

The location for your private key on newer versions
The location for your private key on newer versions

After doing this, scroll back up and click "Session" (the very top option) to go back to the initial view.

In here, under the "Host Name (or IP address)" enter "root@[ip]", where [ip] is the public IP address that you have copied from the Hetzner Cloud screen.

Enter a name for your session under "Saved Sessions", and click Save.

For future PuTTY sessions, you can click the name and click "Load", and it will load your configuration options.

Now click "Open" and it will connect to your server. (If you get a warning, click "Accept").

It will ask you to enter the passphrase you set to unlock your key (if you set one). When you type, your text will not appear on the screen, but it is registering your keystrokes. Just type your passphrase and press enter.

If everything went well, you have now connected to your server, and the bottom line of your terminal should say root@[server-name]:~#

Set up a GTNH server

(Tip: when specifying files in linux you can autocomplete using the tab key).

For the next steps, when you see a command in this formatting, you should execute it by pasting it in your terminal. You can paste using the right mouse button.

Step 1. Update your server's packages to the newest versions.

apt update -y && apt upgrade -y

Step 2. Install java & unzip

apt install openjdk-21-jre-headless unzip -y

Step 3. Download the server zip from the serverpacks download. You want the java 17-21 version. Right click -> copy URL to get the url to download.

wget [URL], e.g. (FOR VERSION 2.6.0), wget http://downloads.gtnewhorizons.com/ServerPacks/GT_New_Horizons_2.6.0_Server_Java_17-21.zip

Step 4. Unzip the server ZIP file into a folder called GTNH-Server. In this case (FOR VERSION 2.6.0),

unzip GT_New_Horizons_2.6.0_Server_Java_17-21.zip -d GTNH-Server

Step 5. Enter the server folder

cd GTNH-Server

Step 6. Edit the startserver-java9.sh file to use your server's capabilities. My server runs on 16GB, so I will set it to 12GB. the default is 6GB.

Step 6a. nano startserver-java9.sh

Step 6b. Go to like 7, where it says "java -Xms6G -Xmx6G ...", and change this to your desired amount, e.g. "java -Xms12G -Xmx12G ..."

Step 6c. Save using CTRL+O, press enter to confirm filename, and quit using CTRL+X

Step 6d. Make the startserver-java9.sh file runnable by using chmod +x startserver-java9.sh

Step 7. Accept the eula

echo "eula=true" > eula.txt

Configuring the mods

This will contain the most basic configuration options, but feel free to add or edit other mods.

Basic terminology:

ls will list all the files in your current directory.

cd [path] will change directory to a certain directory, so cd mods will bring you into the mods folder (if you're in the GTNH-Server folder).

cd .. will change directory to one above your current one, so if you're in mods, cd .. will bring you back to GTNH-Server.

nano [filename] will open a text editor for the file. To find something in a file, do CTRL+W, [string you want to find], enter. to save and quit, do CTRL+O, enter, CTRL+X

mv [file1] [file2] will move file1 to file2, so e.g. if you wanna move a mod that you accidentally downloaded into the main GTNH-Server folder, mv my-mod.jar mods/my-mod.jar would fix that

cp [file1] [file2] will copy file1 to file2.

Pollution

For turning off pollution, do nano config/GregTech/GregTech.cfg

Scroll down until it says "pollution {"

The line below that, edit "B:EnablePollution=true" to "B:EnablePollution=false"

Save and quit (CTRL+O, enter, CTRL+X)

Claiming, homes, etc.

For changing serverutilities settings like chunk claiming etc:

nano serverutilities/serverutilities.cfg

Under "commands {", change all the commands you want working from "false" to "true". if they are set to false, they won't work.

To enable backups, under "backups {" go to the line "B:enable_backups=false" and change it to "B:enable_backups=true". You can also change the amount, backups to keep, timer, etc.

To enable anything in regards to homes, chunk loading, chunk claiming, etc. go to "ranks {" and change "B:enabled=false" to "B:enabled=true".

To enable chunk claiming, go to "world {" and edit "B:chunk_claiming=false" and "B:chunk_loading=false" to "B:chunk_claiming=true" and "B:chunk_loading=true" respectively.

If you want anything like homes, chunk loading, chunk claiming to work, you must now edit nano serverutilities/server/ranks.txt

This guide reccomends adding "default_op_rank: true" to [player] and deleting [vip] and [admin] (and their lines below them). Then, change the remaining settings as wanted.


Running the server

If you run the server on the command line that you are in now, it will turn off when you disconnect. To make the server stay up even when you aren't SSH'd into it, we will create a virtual terminal that keeps running using screen.

To create a new screen / connect to it, do screen -R MC. Press enter. This will create a screen called MC.

In this new screen, you want to run your server. Do this by doing ./startserver-java9.sh. Wait AT THE VERY LEAST 5-10 minutes until the server has started.

Once the server has started, you can whitelist yourself (and your friends) by typing /whitelist add [username]

Then, you can connect to the server by connecting to the IP address in your GTNH client. This is the same IP address you used to SSH into. To detach from the screen, do "CTRL+A, d". To re-attach to the screen, do screen -r MC

To change anything about the config / settings / etc, make sure the server is off by attaching to the screen, typing /stop, and then when it's counting down from 12 to 1, CTRL+C before the countdown is over. Now you can make any edits, and then re-start the server by running ./serverstart-java9.sh again