As root, update the server's installed packages:
> apt-get update
> apt-get upgrade -y
Set default editor (vim):
> update-alternatives --config editor
Allow SSH and Factorio connections:
> ufw allow openssh
> ufw allow 34197/udp
> ufw enable
Configure jail2ban to protect from botnets:
> apt-get install -y fail2ban
# jail.conf is a template, make edits to jail.local
> cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Set server time zone:
> dpkg-reconfigure tzdata
Add user that will run the factorio process and grant it root permissions:
> adduser gamemaster
> usermod -aG admin gamemaster
> usermod -aG sudo gamemaster
Append public key to /home/gamemaster/.ssh/authorized_keys
to enable ssh login as gamemaster.
Enable ssh login only and disable root:
> vim /etc/ssh/sshd_config
--- Make the following config changes ---
ChallengeResponseAuthentication no
PasswordAuthentication no
PermitRootLogin no
UsePAM no
-----------------------------------------
> systemctl reload ssh
Download Factorio:
> su - gamemaster
> wget --content-disposition https://www.factorio.com/get-download/latest/headless/linux64
> tar xf factorio
Configure server settings
> cd factorio/data; cp server-settings.example.json server-settings.json
# Make edits to server-settings.json
Factorio requires a save to initialize. Create the saves directory and upload or create a save game:
> mkdir /home/gamemaster/factorio/saves
> cd /home/gamemaster/factorio/bin/x64
> factorio --create /home/gamemaster/factorio/saves/<name of save game>.zip
As root, create and start the factorio
service:
> cd /etc/systemd/system
> vim factorio.service
--- Paste these settings ---
[Unit]
Description=Factorio service
After=network.target
[Service]
User=gamemaster
ExecStart=/home/gamemaster/factorio/bin/x64/factorio --server-settings /home/gamemaster/factorio/data/server-settings.json --start-server-load-latest --console-log /home/gamemaster/Factorio.log
Restart=always
[Install]
WantedBy=multi-user.target
--------------------------
> systemctl daemon-reload
> systemctl enable factorio
> systemctl start factorio
Server is ready to go. Share the configured game name and password or the IP the game is not "publicly visible".