As you know, we talk about Ubuntu 20.04 and introduce ubuntu focal fossa and a new feature on the Previous article on eldernode. In this article, we talk about post-installation steps for the security, Update, and work with firewall on ubuntu.
After reading this article and follow all steps your server now be ready to use for any services like Webserver, LAMP server, LEMP server, VPN server, MySQL server, or other your favorite service.
Stay with us on Initial server setup on Ubuntu 20.04 ( Focal Fossa )
Initial server setup on ubuntu 20.04
1- Update and Upgrade Your ubuntu 20.04
First of all, login to the Ubuntu 20.04 system via SSH or console. Now, execute the following commands to update apt-cache and upgrade all packages on your system.
sudo apt update sudo apt upgrade
2- Create User Account on Ubuntu 20.04
We don’t recommend to use the root user to work on Ubuntu 20.04. Let’s create an account for system administration and enable sudo access.
sudo adduser newuser
Now add the newly created user to the sudo group, So that it can get all sudo privileges.
sudo usermod -aG sudo newuser
you can replace your favorite name with newuser.
Now you have to change and create new password for this user with following command:
sudo passwd newuser
After enter the command, Ubuntu asks you a password and confirm the password. please use a complex password and use Alphabetic character, Number, signs like [email protected]#$%^&*() .
3- Secure SSH Server
We recommended to change the default SSH port, it helps you to secure your system from bot and hack attempts. To change default port edit OpenSSH configuration file /etc/ssh/sshd_config and do the following changes.
type following command:
Change Default Port. It will be good to change default ssh port as default ports are always on attackers.
before edit: #port 22
after edit (uncomment port 22 and add your favorite port)
Disable Root SSH Login – Also you would like to disable root login via ssh.
After change port and PermitRootLogin, press Ctrl + x and press Enter twice for save and exit the file.
4- Configure Firewall with FirewallD
Next Step on Initial server setup on Ubuntu 20.04 is configured the firewall. The Default Ubuntu 20.04 server edition, do not have firewalld installed on it. You can simply run the following command to install required packages from default repositories.
sudo apt install firewalld
After installation, start firewall service and enable it to auto-start on system boot.
sudo systemctl start firewalld sudo systemctl enable firewalld
By default, the firewall allowed SSH access to remote users. But you need to add your favorite port to add firewalld because we change on the last step and also you may also need to allow other services through the firewall to remote users.
Now. the first command must be added ssh new port.
firewall-cmd --permanent --add-port=2245/tcp
You can directly provide a service name like “http” or “https” to allow. The firewalld uses /etc/services file to determine the corresponding port of the service.
firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https
If any of the service names is not defined in /etc/services file. You can firewall rule using the port number directly. For example, to allow TCP port 2080 to your firewall.
firewall-cmd --permanent --add-port=2080/tcp
After making any changes to your firewall, make sure to reload changes using the following command.
To view, all the allowed services and port use the following command.
firewall-cmd --permanent --list-all
you see output like these:
Output: public target: default icmp-block-inversion: no interfaces: sources: services: cockpit dhcpv6-client http https ssh ports: 2080/tcp 2245/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
Now your ubuntu 20.04 server ready to use, and your sever post-installation is complete.
I hope to enjoy the Initial server setup on ubuntu 20.04 on eldernode.
you could another post about ubuntu 20.04 on Ubuntu 20.04 tutorials.