Securing the Server
User configuration:
- Add your username.
adduser yourusername - Set your password.
passwd yourusername - Set credentials.
visudo## Allow root to run any commands anywhere root ALL=(ALL) ALL yourusername ALL=(ALL) ALLTo save your configuration, press escape key then input the following command, then hit enter.
:wq
SSH security (login access security):
- Login with your username, input your password if asked.
ssh yourusername@your_ipv4 - Generate your SSH key. You can do it on a Linux bash command line or Windows (PuTTYgen) computer. In this case, I have used Linux.
ssh-keygen - Upload it to your server using the command below.
scp ~/.ssh/id_rsa.pub yourusername@your_ipv4: - Create a directory from your server.
mkdir .ssh - Move and change permission to the public key.
mv id_rsa.pub .ssh/authorized_keyschown -R example_user:example_user .ssh chmod 700 .ssh chmod 600 .ssh/authorized_keys - Browse SSH configuration.
sudo nano /etc/ssh/sshd_config - Disable root login and use ssh authentication by updating to the data below.
PasswordAuthentication no PermitRootLogin no - Restart SSH using the command below.
sudo systemctl restart sshd
Firewall Configuration (Using FirewallD):
- Enable the firewall service using the command below.
sudo firewall-cmd --permanent --add-service=ssh - Input the following command if you want to use a new port and restarted your SSH server.
sudo firewall-cmd --permanent --remove-service=ssh sudo firewall-cmd --permanent --add-port=4444/tcp - For HTTP server, enable the service using the command below.
sudo firewall-cmd --permanent --add-service=http - For HTTPS or SSL server, enable the service using the command below.
sudo firewall-cmd --permanent --add-service=https - For email or SMTP server, enable the service using the command below.
sudo firewall-cmd --permanent --add-service=smtp - To check for additional services, type the following command.
sudo firewall-cmd --get-services - To check if for your configuration, type the command below.
sudo firewall-cmd --permanent --list-all - If you are finished, restart or reload your firewall.
sudo firewall-cmd --reload - Lastly, enable your firewall at boot by the command below.
sudo systemctl enable firewalld












