Congratulations on your new VPS server running Ubuntu! Here are some essential steps you should take to set up your server:
-
Update the system: Begin by updating the package repositories and upgrading all the installed packages on your server. This ensures that you have the latest security patches and bug fixes. Run the following commands:
sudo apt update sudo apt upgrade
-
Secure your server: Strengthen the security of your VPS by configuring the firewall and enabling only necessary network services. Ubuntu uses UFW (Uncomplicated Firewall) as a front-end to manage firewall rules. To enable UFW and allow SSH access, execute the following commands:
sudo ufw enable sudo ufw allow OpenSSH
-
Create a non-root user: Using the root account for day-to-day tasks is not recommended due to security risks. Create a new user with sudo privileges, and use that account for regular operations. Replace
yourusername
with the desired username in the following command:sudo adduser yourusername sudo usermod -aG sudo yourusername
-
Configure SSH access: Modify the SSH configuration to enhance security. Open the SSH configuration file using a text editor like Nano:
sudo nano /etc/ssh/sshd_config
Make the following changes:
- Set
PermitRootLogin
tono
to disable root login. - Uncomment
PasswordAuthentication
and set it tono
to enforce key-based authentication. - Optionally, change the SSH port by modifying
Port
(use a non-standard port for added security).
Save the file and restart the SSH service for changes to take effect:
sudo systemctl restart sshd
- Set
-
Set up SSH key authentication: Generate an SSH key pair on your local machine if you haven't already done so. Copy the public key to your VPS server to enable key-based authentication:
ssh-copy-id yourusername@your_server_ip
-
Install useful software: Install essential software packages that are commonly used on Ubuntu servers. While the specific requirements vary depending on your use case, some common packages to consider include
fail2ban
for intrusion prevention,unattended-upgrades
for automatic security updates, andhtop
for system monitoring.
These steps should provide a good foundation for setting up your VPS server. Remember to always keep your server updated, regularly backup your data, and follow security best practices to ensure a secure and stable environment.