-
Notifications
You must be signed in to change notification settings - Fork 1
System wide Masternode Setup with Systemd auto (re)start RFC
Welcome to the Hilux-Master-Node wiki!
Login to the VPS as root and change the password of this user to something complicated and long, write it down and keep it safe.
Code: passwd root
We will create two new users, one to administer the server and one to run the Hilux
service. We abide my the principle of least privilege https://en.wikipedia.org/wiki/Principle_of_least_privilege
as that will increase the security of the server.
Code: useradd -m -c Hilu Hilu -s /bin/bash useradd -m -c "HiluxdT Admin" Hiluxadmin -s /bin/bash -G sudo,hilu
For the dash user, choose a very random long passwd. You don't have to remember this password or write it down, it will never be used.
Code: < /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo passwd dash
For the hiluxadmin user, choose a long password and write it down, this is the password you will use from now on to login into the VPS and administer the masternode.
Code: passwd dashadmin
Now it is time to logout and try logging in with your dashadmin user and password. To logout, press CTRL+D in the PuTTY (shell) window, or type exit, or type logout until the window is closed, avoid pressing the X icon to close this window.
Make sure you are now logged in as hiluxadmin and not root, check with the output from the below command.
Code: whoami
For security reasons we want to disable remote logins to the root user from now on. This user exists on every UNIX/Linux machine and is being brute force attacked on your machine all the time! Run the below block. Copy & paste the block in one go into the terminal (PuTTY).
Code:
if (( $(id -u) != 0 )); then
sudo bash -c
"grep -q ".PermitRootLogin [ny][oe]." /etc/ssh/sshd_config &&
sed -i 's/.PermitRootLogin [ny][oe]./PermitRootLogin no/g' /etc/ssh/sshd_config||
echo "PermitRootLogin no">>/etc/ssh/sshd_config"
else echo "Only run this block as your hiluxadmin user, not root."; fi
Code: sudo apt update# Configure swap space so that the VPS has at least 1GB of swap, this helps with avoiding crashes when the RAM is running low.
Code:
if (( $(free -m|grep Swap|awk '{print $2}') < 2048 ))
then
echo "Adding 2GB swap..."
sudo bash -c "fallocate -l 2G /var/swapfile&&
chmod 600 /var/swapfile&&
mkswap /var/swapfile&&
swapon /var/swapfile&&
grep -q "^/var/swapfile.none.swap.sw.0.0" /etc/fstab ||
echo -e "/var/swapfile\tnone\tswap\tsw\t0\t0" >>/etc/fstab"
else
echo "You already have enough swap space."
fi
Memory management. We want the VM to use memory more effectively and prevent crashes due to low memory. Run the below to set this parameter.
Code: sudo bash -c "echo "vm.overcommit_memory=1">>/etc/sysctl.conf"
Time now to let the above changes take effect and make sure the VPS is able to reboot properly. Run the below command to reboot the VPS, your terminal session will automatically close.
Code: sudo reboot
Make sure you are now logged in as hiluxadmin and not root, check with the output from the below command.
sudo apt upgrade
Code: sudo apt install ufw python virtualenv git unzip pv speedtest-cli