How to Set Up Automated Updates on Your Dedicated Server

Automating updates on your dedicated server ensures that your system remains secure, up-to-date, and runs smoothly without requiring manual intervention. Follow these steps to set up automated updates for your server.

Step 1: Connect to Your Dedicated Server via SSH

  • Open your terminal (Linux/Mac) or an SSH client (Windows) such as PuTTY.
  • Log in to your dedicated server using the root credentials.
    ssh root@your-server-ip
    

Step 2: Update Your Package List

  • Run the following command to ensure your package list is up to date.
    apt-get update
    

Step 3: Install Unattended Upgrades

  • Unattended upgrades allow your server to install security updates automatically.
  • To install it, use the following command:
    apt-get install unattended-upgrades
    

Step 4: Configure Unattended Upgrades

  • Open the configuration file for unattended-upgrades.
    nano /etc/apt/apt.conf.d/50unattended-upgrades
    
  • Enable automatic updates for security packages by modifying the file. Make sure the lines below are uncommented:
    Unattended-Upgrade::Allowed-Origins {
      "${distro_id}:${distro_codename}-security";
    };
    
  • Save and exit the editor (press Ctrl + X, then press Y, and hit Enter).

Step 5: Enable Unattended Upgrades

  • To enable the service that runs the automatic upgrades, use this command:
    dpkg-reconfigure --priority=low unattended-upgrades
    
  • Select Yes when prompted to enable automatic updates.

Step 6: Set Up Automatic Updates for Regular Packages

  • To install regular (non-security) updates automatically, configure your APT settings by editing the following file:
    nano /etc/apt/apt.conf.d/10periodic
    
  • Add or ensure the following lines are present:
    APT::Periodic::Update-Package-Lists "1";
    APT::Periodic::Download-Upgradeable-Packages "1";
    APT::Periodic::AutocleanInterval "7";
    APT::Periodic::Unattended-Upgrade "1";
    
  • Save and exit the file.

Step 7: Verify the Configuration

  • To verify if unattended-upgrades are running correctly, check the log files:
    cat /var/log/unattended-upgrades/unattended-upgrades.log
    
  • You can also manually trigger an update to ensure everything is set up:
    unattended-upgrade --dry-run
    

Step 8: (Optional) Set Up Email Notifications for Updates

  • To receive email notifications whenever updates are installed, open the configuration file:
    nano /etc/apt/apt.conf.d/50unattended-upgrades
    
  • Add your email address to the following line:
    Unattended-Upgrade::Mail "your-email@example.com";
    
  • Save and close the file.

Conclusion

By setting up automated updates on your dedicated server, you can ensure that your system stays up to date with the latest security patches and performance improvements without requiring manual effort. Regular updates help to safeguard your server from potential vulnerabilities, keeping it secure and running optimally.

Was this answer helpful? 0 Users Found This Useful (0 Votes)