Get your Ubuntu server production-ready with this essential initial setup guide covering user management, firewall, and SSH hardening.
This comprehensive guide will walk you through installing Ubuntu Server on Ubuntu 22.04 LTS. Follow these steps carefully to ensure a successful installation.
First, ensure your system is up to date:
sudo apt update && sudo apt upgrade -y
Install required dependencies:
sudo apt install ufw fail2ban curl wget git -y
Now install Ubuntu Server using the package manager:
# Create a new sudo user
adduser deployer
usermod -aG sudo deployer
# Set up SSH key authentication
mkdir -p /home/deployer/.ssh
cp ~/.ssh/authorized_keys /home/deployer/.ssh/
chown -R deployer:deployer /home/deployer/.ssh
chmod 700 /home/deployer/.ssh
chmod 600 /home/deployer/.ssh/authorized_keys
Start the Ubuntu Server service and enable it to run on boot:
# Disable root login and password authentication
sudo sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
sudo systemctl restart sshd
Edit the configuration file located at /etc/ssh/sshd_config:
sudo nano /etc/ssh/sshd_config
Check that Ubuntu Server is running correctly:
sudo ufw status
sudo systemctl status sshd
sudo systemctl status fail2ban
Congratulations! You now have Ubuntu Server running on Ubuntu 22.04 LTS. For additional configuration options, refer to the official Ubuntu Server documentation.