Essential Steps After Installing Ubuntu Server Locally

September 13, 2024

Installing Ubuntu Server locally is the first step toward building a powerful, flexible server environment. However, the installation alone is not enough to get your server fully operational. To help you set up your Ubuntu Server effectively, we've compiled a comprehensive list of the most important tasks to perform right after the installation. Whether you are a beginner or an experienced user, these steps will help you secure, optimize, and enhance your server for various applications.

1. Update and Upgrade the System

The first step after installing Ubuntu Server is to update the package lists and upgrade the installed packages to the latest versions. This ensures your server is protected against any known vulnerabilities and has access to the latest features.

sudo apt update && sudo apt upgrade -y

Additionally, consider enabling automatic updates for security patches:

sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades

For more details on updating Ubuntu, check the official Ubuntu Documentation.

2. Set Up a Static IP Address

If your server needs to be accessible on a local network or via the internet, a static IP address is crucial. You can configure it by editing the Netplan configuration file:

sudo nano /etc/netplan/01-netcfg.yaml

Add the static IP configuration:

network:
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4
  version: 2

Apply the changes:

sudo netplan apply

3. Secure SSH Access

SSH (Secure Shell) is the most common way to access your server remotely. For improved security:

  • Change the default SSH port from 22 to something less common to avoid automated attacks.
  • Disable root login to prevent unauthorized access.
  • Use SSH keys instead of passwords for authentication.

Edit the SSH configuration file:

sudo nano /etc/ssh/sshd_config

Change the following lines:

Port 2222
PermitRootLogin no
PasswordAuthentication no

Restart SSH:

sudo systemctl restart ssh

For more tips on securing SSH, see this SSH Security Guide.

4. Install a Firewall

Ubuntu comes with ufw (Uncomplicated Firewall) pre-installed, which is a user-friendly way to manage iptables firewall rules. To enable the firewall:

sudo ufw allow OpenSSH
sudo ufw enable

To allow additional services like HTTP or HTTPS:

sudo ufw allow http
sudo ufw allow https

Learn more about ufw in the Ubuntu Server Guide.

5. Install Fail2Ban

Fail2Ban is a security tool that protects your server from brute-force attacks. It monitors the server logs and bans IPs that show malicious signs, like too many failed login attempts.

To install Fail2Ban:

sudo apt install fail2ban

To enable it, configure the jail:

sudo nano /etc/fail2ban/jail.local

Add the following:

[sshd]
enabled = true
port = 2222
filter = sshd
logpath = /var/log/auth.log
maxretry = 5

Restart Fail2Ban:

sudo systemctl restart fail2ban

6. Create Regular Backups

Regular backups are essential for data integrity and disaster recovery. Ubuntu provides various tools like rsync for file backups and Timeshift for system backups. Set up automated backups to an external drive or a remote location.

For more options on creating backups, refer to the Ubuntu Backup Guide.

7. Monitor System Performance

Install monitoring tools like htop, glances, or netdata to keep an eye on server performance, including CPU usage, memory usage, disk activity, and network traffic.

To install htop:

sudo apt install htop

These tools help you identify bottlenecks and ensure the server is running smoothly.

8. Install Essential Software

Depending on your use case, you may want to install additional software:

  • LAMP stack: For web hosting (Apache, MySQL, PHP).
  • Docker: For containerization.
  • Nginx: As an alternative to Apache.

To install the LAMP stack:

sudo apt install apache2 mysql-server php libapache2-mod-php

Check out the LAMP Stack Guide for more information.

Conclusion

By completing these essential steps after installing Ubuntu Server, you are setting up a secure, reliable, and efficient environment ready to handle various workloads. Whether you plan to host websites, run applications, or manage network services, these configurations provide a solid foundation for your server.


External Links for Further Reading:

By following these steps, you'll ensure that your Ubuntu Server is well-protected, optimized, and ready for production or development use.


Happy coding! 🎉

Follow Me