Last Updated: 9/14/2021 – included backup script
This guide is for all the gamers who want to manage their own dedicated Valheim server. Learn how to do it before the “Hearth and Home” update releases later this year. This guide will be done using Digital Ocean Cloud Servers, which I have been using for the past five-plus years both professionally and for personal projects. If you use Google Cloud Platform/Azure/AWS or others, the process is pretty similar.
If you are looking for the Windows version of this guide go here.
Prerequisites
- Some knowledge of Linux/Ubuntu
- Your Own Website Domain (Recommended)
- This guide can easily accommodate between 2 to 10 Players
Section 1: Build a server on Digital Ocean
- Use this link to get $100 worth of free Digital Ocean credits (Valid for 60 Days)
- Create an Account and Logon to Digital Ocean
- Click “Create” select “Droplets“

- On the “Create Droplets” screen choose “Ubuntu 20.04 LTS“

- Under “Choose a Plan” select “Basic” and “Regular Intel with SSD“
- Also select “4GB/2 CPU + 80GB SSD“

- Skip “Add block storage”
- On the “Choose a datacenter region” select a location that is closest for you and your friends. Since most of my friends are located within the eastern USA time zone I am going to select New York.

- Skip “VPC Network”
- Skip “Select additional options”


- Select “Password” unless you know how to use SSH keys. 🙂
- For “Create root password”, create a super-long-random-complex-password. Save this password as we will need this for connecting and managing this virtual machine.

- For “Choose a hostname” enter a name preferably a subdomain of the domain name you own.
- E.g. I am going to use “val.cloudrigs.com” we will connect this to our DNS/Registrar in a later step.
- This is just a label but in some other apps it can be sent as a header.
- If you do not have a domain name. You can name it anything you wish such as ValheimFriendServer.

- Now scroll down to the bottom and click “Create Droplet“, in just a few short minutes your Digital Ocean powered Ubuntu machine will be ready to go.

- Once the Ubuntu server has been created it will look like the following. Write down this Droplet IP mine is 143.198.14.227

Section 2: Setup Firewall Rules
- Go to www.whatismyip.com and write down your public IP from your computer, mine is 136.57.10.10
- Log back into Digital Ocean and on the left side select “Networking” then select “Firewalls” and click “Create Firewall“
- Create a name such as “Valheim-Firewall”

- Configure the following “Inbound Rules”. For SSH use your public IP from your ISP (which we got in Section 2, Step 1). This is to reduce bots and attackers from trying to bruteforce your root account. This ensures only your IP is authorized to connect.
- Make sure “UDP” and port range is “2456-2458” setup.

- Configure the following “Outbound Rules”. These should already exist.

- Under “Apply to Droplets” type in the name of the server you originally created. I will type in the name of my droplet, so the firewall rules apply to it. Then click “Create Firewall“

Section 3: Create a DNS entry with your own domain (otherwise skip to Section 4)
- Now, its time to map the static IP of your Droplet IP to your DNS provider. In my case I am using CloudFlare so I am going to create a DNS entry to map “val.cloudrigs.com” to my Droplet IP of 143.198.14.227. I am doing this now so the DNS value has time to propagate throughout the world.
- Here is what it looks like in my CloudFlare account. Notice I am using DNS only. I am not using the proxy option.


Section 4: Connect to the server and Install Valheim
- Grab the IP from the droplet: 143.198.14.227
- If you do not have Putty download it and run it. It should look like this: Enter in the droplet IP into the “Host Name” field

- Click “Open” then click “Accept/I trust” the fingerprint verification screen.
- Login as: root
- Password: <the password you wrote down before> , if you copy the password, you can paste by right-clicking into the putty window. Just keep in mind, that no feedback is displayed when typing in any passwords. If you press enter it should connect.
- Once connected you should see the following

- Run the following command, this will update and install the latest Ubuntu packages.
sudo apt-get update && sudo apt-get -y upgrade

- If you get the following message press the “tab” key then press enter on “Ok”

- Type the following command, then press enter
reboot
- Give the server a minute to reboot, then reconnect to putty and run this
sudo apt-get install -y git net-tools htop
- Navigate to the folder by typing “/opt” then press enter
cd /opt
- Download the Valheim Script created by Nimdy and updated by many contributors.
git clone https://github.com/Nimdy/Dedicated_Valheim_Server_Script.git
- Change to the following directory
cd Dedicated_Valheim_Server_Script
- Here we are going to change the permissions so this script can be executed.
chmod +x njordmenu.sh
- Launch the Nimdy Njord Menu Script.
sudo ./njordmenu.sh
- This is what you should see

- Select Option 3, by typing “3” and pressing enter.


- Select Option “1” and press enter (I think you got it)

- The Steam server software will start to download and install.

- Follow the on-screen instructions for creating a local Ubuntu account to run the game server. Press enter to proceed to the next step.

- Create a name for your server. This name will show in the Valheim public listing directory. Notice: Do not use special characters in your name.

- Create the world name for your server. I named mine “OdinsGate”.

- Select “1” to set your server public

- Set a password that you will share with your friends so they can access the server. Password must be at least 5 characters long.

- Valheim server will begin to install, this process will take 3-5 minutes.

- When completed you will see the following. You can press 0 to go to the main menu. It can take up to 20 minutes for your server to show up in the Valheim directory listing.


Congratulations your Valheim Server is live!!
Now your users can connect with just the domain name val.cloudrigs.com instead of by IP.
If you do not have your own domain name, just provide the droplet IP to your friends. In this example that would be 143.198.14.227
Bonus Content
- What happens if my home network’s IP changes?
- Logon to digital ocean and replace the Inbound SSH IP with your new one. This may seem annoying but it offers a lot of protection to your environment.
- How can I tell if my server is running?
- You can review by selecting option “16” in the menu or by running the following command
systemctl status valheimserver.service
- How do I get back into the menu?
- Use the following command
cd /opt/Dedicated_Valheim_Server_Script
sudo ./njordmenu.sh
- How do I reboot the server?
- Use the following command
sudo reboot
- I accidently shutdown the server how to I power it back on?
- Logon to digital ocean select the droplet, select “Power” then click “Turn On”

- Do you have a script to backup the server? Yes, see the script below. named “valheimbackup.sh” make sure this script has execute permissions “sudo chmod +x valheimbackup.sh” . View this post to use cronjob.
#!/bin/bash
## Get the current date as variable.
TODAY="$(date +%Y-%m-%d--%mm)"
## Clean up files older than 3 weeks.
find /home/steam/backups/ -mtime +21 -type f -delete
#systemctl stop the service (based off the service name)
systemctl stop valheimserver_ThorsHammerWorld.service
#Wait for RAM to offload to .db and .db.old
#allows for the closing of the databases.
sleep 120
## Tar Section. Create a backup file, with the current date in its name.
## Add -h to convert the symbolic links into a regular files.
## Backup some system files, also the entire `/home` directory, etc.
## --exclude some directories, for example the the browser's cache, `.bash_history`, etc.
tar zcvf "/home/steam/backups/valheim-backup-$TODAY.tgz" /home/steam/.config/unity3d/IronGate/Valheim/*
chown steam:steam /home/steam/backups/valheim-backup-$TODAY.tgz
Leave a Reply