How to Connect to Your VDS Server via SSH (Complete Guide)
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Install and configure unattended-upgrades, security-only updates, email notifications, testing, risks and mitigations for Linux servers.
One of the most fundamental server security requirements is timely application of security patches. Forgetting to update manually can leave your server vulnerable to known security exploits. The unattended-upgrades package automatically applies security updates on Ubuntu and Debian systems. This guide covers installation, configuration, and best practices.
unattended-upgrades is an APT plugin that automatically downloads and installs security updates without human intervention. It's ideal for:
Automatic updates can sometimes cause service interruptions. Kernel updates in particular require a reboot. Configure carefully in production environments.
# Install the package
sudo apt update
sudo apt install unattended-upgrades apt-listchanges -y
# Verify installation
dpkg -l unattended-upgrades
# Check service status
systemctl status unattended-upgrades
# Auto-configure basic settings
sudo dpkg-reconfigure -plow unattended-upgrades
# Select "Yes"
Main configuration file: /etc/apt/apt.conf.d/50unattended-upgrades
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
// Ubuntu security updates
"${distro_id}:${distro_codename}-security";
// ESM security updates (Ubuntu Pro)
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
// All updates (not recommended — prefer security-only)
// "${distro_id}:${distro_codename}";
// "${distro_id}:${distro_codename}-updates";
};
// Exclude specific packages from updates
Unattended-Upgrade::Package-Blacklist {
// "nginx";
// "mysql-server";
// "php*";
};
// Automatic reboot after updates
Unattended-Upgrade::Automatic-Reboot "false";
// Reboot time (only if Automatic-Reboot is true)
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
// Remove unused dependencies
Unattended-Upgrade::Remove-Unused-Dependencies "true";
// Remove unused kernel packages
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
// Email notification
Unattended-Upgrade::Mail "admin@rexe.tr";
// Send email only on change
Unattended-Upgrade::MailReport "on-change";
// Options: "always", "only-on-error", "on-change"
// Keep update log
Unattended-Upgrade::SyslogEnable "true";
Unattended-Upgrade::SyslogFacility "daemon";
Update frequency is configured in /etc/apt/apt.conf.d/20auto-upgrades:
sudo nano /etc/apt/apt.conf.d/20auto-upgrades
// Update package list daily
APT::Periodic::Update-Package-Lists "1";
// Download upgradeable packages daily
APT::Periodic::Download-Upgradeable-Packages "1";
// Run unattended-upgrades daily
APT::Periodic::Unattended-Upgrade "1";
// Clean old package cache every 7 days
APT::Periodic::AutocleanInterval "7";
Values are in days. "1" = daily, "7" = weekly, "0" = disabled.
Applying only security updates automatically is the safest approach for production servers:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
// ONLY security updates
"${distro_id}:${distro_codename}-security";
};
// Comment out all other update sources
// "${distro_id}:${distro_codename}";
// "${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-backports";
mailutils or postfix is required for update notifications:
# Install mailutils
sudo apt install mailutils -y
# For simple SMTP configuration
sudo apt install ssmtp -y
sudo nano /etc/ssmtp/ssmtp.conf
root=admin@rexe.tr
mailhub=smtp.gmail.com:587
AuthUser=your-email@gmail.com
AuthPass=your-app-password
UseTLS=YES
UseSTARTTLS=YES
# Test email
echo "Test message" | mail -s "Server Update Test" admin@rexe.tr
# Simulate without actually updating
sudo unattended-upgrade --dry-run --debug
# More verbose output
sudo unattended-upgrade -d --dry-run
# Run unattended-upgrades immediately
sudo unattended-upgrade -d
# Run in verbose mode
sudo unattended-upgrade --verbose
# Main log file
cat /var/log/unattended-upgrades/unattended-upgrades.log
# Error logs
cat /var/log/unattended-upgrades/unattended-upgrades-dpkg.log
# Real-time log monitoring
tail -f /var/log/unattended-upgrades/unattended-upgrades.log
# Check last update time
ls -la /var/log/unattended-upgrades/
Kernel updates require special attention:
# Check if a reboot is required
cat /var/run/reboot-required
# See which packages require a reboot
cat /var/run/reboot-required.pkgs
# Check if reboot is needed
if [ -f /var/run/reboot-required ]; then
echo "Reboot required!"
fi
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
// Enable automatic reboot
Unattended-Upgrade::Automatic-Reboot "true";
// Reboot time (2:00 AM)
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
// Don't reboot if users are logged in
Unattended-Upgrade::Automatic-Reboot-WithUsers "false";
Before enabling automatic reboots, assess whether your application can tolerate restarts. Manual reboots are preferred for critical production systems.
# 1. Blacklist critical packages
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Package-Blacklist {
// Critical database server
"mysql-server";
"postgresql";
// Web server
"nginx";
"apache2";
// Kernel (for manual updates)
"linux-image*";
"linux-headers*";
};
# 2. Take a snapshot before updates (on supported systems)
# 3. Regularly check update logs
tail -100 /var/log/unattended-upgrades/unattended-upgrades.log
# 4. Check service status after updates
systemctl --failed
RPM-based systems use dnf-automatic:
# Install
sudo dnf install dnf-automatic -y
# Configure
sudo nano /etc/dnf/automatic.conf
[commands]
# Security updates only
upgrade_type = security
# Apply updates automatically
apply_updates = yes
[emitters]
# Email notification
emit_via = email
email_to = admin@rexe.tr
[email]
email_from = server@rexe.tr
email_host = localhost
# Enable the service
sudo systemctl enable --now dnf-automatic.timer
# Check status
sudo systemctl status dnf-automatic.timer
# List timers
sudo systemctl list-timers dnf-automatic*
On both Ubuntu and CentOS systems, closely monitor log files during the first week after enabling automatic updates. This helps you catch unexpected issues early.
unattended-upgrades is a powerful tool for keeping your REXE servers secure. By automatically applying only security updates, blacklisting critical packages, and enabling email notifications, you can maintain both a secure and stable server environment. Regular log checks and validation in a test environment make the automatic update process more reliable.
By default, it installs only security updates. You can control which update sources are used in the Allowed-Origins section of /etc/apt/apt.conf.d/50unattended-upgrades. For production servers, it's recommended to keep only the '-security' source active.
By default, it runs once a day. The exact time varies based on the system's APT timer (usually at night). You can adjust the frequency in /etc/apt/apt.conf.d/20auto-upgrades. You can also customize it with a systemd timer.
Add the package name to the Package-Blacklist section in the 50unattended-upgrades file. For example, to exclude nginx, add '"nginx";'. You can use wildcards: '"php*";' excludes all PHP packages.
Set 'Unattended-Upgrade::Automatic-Reboot "false";' in the 50unattended-upgrades file. This prevents any update, including kernel updates, from triggering an automatic reboot. You can then schedule reboots manually.
Several methods: check service status with 'systemctl status unattended-upgrades', review the log file with 'cat /var/log/unattended-upgrades/unattended-upgrades.log', or run a simulation with 'sudo unattended-upgrade --dry-run'.
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Complete guide to connecting to Windows Server VDS via Remote Desktop (RDP): setup steps, NLA security, Path Panel firewall rule, and troubleshooting tips.
Step-by-step guide to changing your VDS server OS via REXE panel: backup tips, supported Linux distributions and Windows Server versions explained.