19
loading...
This website collects cookies to deliver better user experience
dnf update
useradd <Admin-name>
passwd <Admin-name>
useradd <service-account>
passwd <service-account>
vim
and tmux
, and screen
.Vim
and tmux
are easy to install:dnf install vim tmux java-16-openjdk-devel
epel
(Extra Packages for Enterprise Linux), which can be installed like so:dnf install epel-release
dnf install screen
ssh keys
to login to those accounts. The key is to make sure that the permissions of the files related to ssh are correct:su <username>
chmod 0700 .
mkdir .ssh
chmod 0700 .ssh
# Paste the ssh key in this file
vim .ssh/authorized_keys
chmod 0600 .ssh/authorized_keys
server.jar
which you can get from Mincraft.net or from the Launcher itself (if your server is going to be using snapshots, or a version other than the most recent release, then you are going to want to go the launcher route).jars
directory, this way it is easy to roll back to previous versions if need be.
mkdir -p server/jars
cd jars
# The following command will download Mincraft server version 1.16.5 to the current directory
curl https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar --output server-1.16.5.jar
# Create a symbolic link to the current jar file, to change which jar file the server will be using, you can modify which jar the current.jar link points to
ln -s server-1.16.5.jar current.jar
# Return to the main server directory
cd ..
eula.txt
files. We can do this with the following command:
java -jar jars/current.jar
eula.txt
read through the terms and conditions in the supplied URL, and then set eula=true
to agree to them.server.properties
file. These settings are outside of the scope of this post, bu if you want to learn more about what each of these properties do you can read about them here.curl -O https://raw.githubusercontent.com/BrandonDusseau/minecraft-scripts/master/startmc.sh
curl -O https://raw.githubusercontent.com/BrandonDusseau/minecraft-scripts/master/backup.sh
10.
<mcserveruser>
and use an amount of RAM that is appropriate for your server in the JVMARGS section (-Xmx/Xms)
# startmc.sh
MCDIR="/home/<mcserveruser>/server"
JVMARGS="-XmxM3072M -Xms3072M -d64"
MCJAR="jars/current.jar"
MCSCREENNAME="minecraft"
# backup.sh
# File and directory configuration
# Ensure these directories have correct permissions
# Do not add trailing slashes
MCDIR="/home/mcserveruser/server"
BACKUPDIR="${MCDIR}/backups"
chmod +x backup.sh startmc.sh
./startmc.sh
./backups.sh
vim /etc/ssh/.sshd_config
# Find the line below
Port 22
# Chang it to something random, like
Port 5052
SELinux
will prevent sshd
from starting on any port other than 22, so we will need to do a few more things to make the change take effect.semanage port -a -t ssh_port_t -p tcp 5052
systemctl restart sshd
firewalld
:dnf install firewalld
systemctl start firewalld
systemctl enable firewalld
tcp
traffic through two ports:# Let Minecraft through the firewall
firewall-cmd --add-port=25565/tcp --zone=public --permanent
# Let our ssh traffic through the firewall
firewall-cmd --add-port=5056/tcp --zone=public --permanent
chattr +i /etc/passwd
chattr +i /etc/shadow
dnf install fail2ban
systemctl start fail2ban
systemctl enable fail2ban
# Configure by adding the following file
vim /etc/fail2ban/jail.local
# Add the following to the file mentioned above
[DEFAULT]
# Ban hosts for one hour:
bantime = 3600
# Override /etc/fail2ban/jail.d/00-firewalld.conf:
banaction = iptables-multiport
[sshd]
enabled = true
# Restart the service
systemctl restart fail2ban
19