Setting Up an Ubuntu Server¶
1. Accessing the Server¶
Access the server using an SSH client, substituting server_ip with the server IP address:
2. Updating the Server¶
Update the server to ensure all packages are up to date:
3. Creating a New User¶
Create a new user with sudo privileges to avoid using the root account:
4. Configuring SSH Access¶
Configure SSH access by copying SSH keys from the root user to the new user:
Update SSH configuration to disable root login and password authentication:
Make the following changes:
Note
In Ubuntu 22.04.1 LTS, the /etc/ssh/sshd_config.d/50-cloud-init.conf file might override settings from sshd_config, including the PasswordAuthentication setting. To ensure that PasswordAuthentication is disabled, review and adjust the settings in this file.
Restart the SSH service:
5. Setting Up a Firewall¶
Configure the firewall to allow essential services:
6. Disabling Root Login¶
Disable root login for additional security:
7. Fail2ban¶
Install Fail2ban to protect the server from brute-force attacks:
Start and enable Fail2ban:
Check the status of Fail2ban to ensure it is running correctly: