Aug 232011
 

Il pensiero che un server si aggiorni automaticamente (e magari faccia anche reboot) non è in effetti una cosa che mi fa stare così tranquillo, ma è sicuramente meglio che non applicare delle patch gravi bug di sicurezza che potrebbero esporre i servizi a grossi rischi.

Quindi oggi vedremo come utilizzare il pacchetto unattended-upgrades , è disponibile in Debian e Ubuntu e può aiutare a programmare cosa e quando aggiornare automaticamente sui vostri computer.

Installazione

Il pacchetto è disponibile nei repository quindi si può usare il vostro gestore di pacchetti preferito, come ad esempio

sudo aptitude install unattended-upgrades

Configurazione

La prima cosa da impostare sono le preferenze per il pacchetto apt, fatelo creando il file / etc/apt/apt.conf.d/02periodic , che potrebbero contenere questi parametri:

APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "5";
APT::Periodic::Unattended-Upgrade "1";

Explanation of these parameters

# APT::Periodic::Enable “1”;
# – Attiva lo script di aggiornamento/upgrade (0=disable)

# APT::Periodic::Update-Package-Lists “1”;
# – Fai “apt-get update” automaticamente ogni n-giorni (0=disable)

# APT::Periodic::Download-Upgradeable-Packages “1”;
# – Fai “apt-get upgrade –download-only” ogni n-giorni (0=disable)

# APT::Periodic::AutocleanInterval “0”;
# – Fai “apt-get autoclean” ogni n-giorni (0=disable)

# APT::Periodic::Unattended-Upgrade “0”;
# – Esegue lo script per gli upgrade di sicurezza “unattended-upgrade”
# ogni n-giorni (0=disabled)
# Richiede il pacchetto “unattended-upgrades” e scriverà
# un log in /var/log/unattended-upgrades

Preferenze per unattended-upgrades

Ora date un’occhiata al file /etc/apt/apt.conf.d/50unattended-upgrades, quello che segue è il default, che dovrebbe andare bene per la maggior parte delle installazioni:

// Automatically upgrade packages from these (origin, archive) pairs
Unattended-Upgrade::Allowed-Origins {
        "${distro_id} stable";
        "${distro_id} ${distro_codename}-security";
//      "${distro_id} ${distro_codename}-updates";
//      "${distro_id} ${distro_codename}-proposed-updates";
};
 
// List of packages to not update
Unattended-Upgrade::Package-Blacklist {
//      "vim";
//      "libc6";
//      "libc6-dev";
//      "libc6-i686";
};
 
// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. The package 'mailx'
// must be installed or anything that provides /usr/bin/mail.
//Unattended-Upgrade::Mail "root@localhost";
 
// Do automatic removal of new unused dependencies after the upgrade
// (equivalent to apt-get autoremove)
//Unattended-Upgrade::Remove-Unused-Dependencies "false";
 
// Automatically reboot *WITHOUT CONFIRMATION* if a
// the file /var/run/reboot-required is found after the upgrade
//Unattended-Upgrade::Automatic-Reboot "false";
 
 
// Use apt bandwidth limit feature, this example limits the download
// speed to 70kb/sec
//Acquire::http::Dl-Limit "70";

Per iniziare questa configurazione è abbastanza buona, avrete gli aggiornamenti di sicurezza installati automaticamente.
Tutto è fatto, grazie al cron presente in /etc/cron.daily/apt ogni giorno la vostra configurazione verrà letta e verrano eseguiti gli aggiornamenti.


Riferimenti:

Ubuntu Wiki

Popular Posts:

Flattr this!

  4 Responses to “Abilitare gli aggiornamenti automatici di sicurezza in Debian/Ubuntu”

  1. wouldn’t setting up a cron job be easier?

    • Different for sure, easier i don’t know.
      With this setup you use the apt cron that you any debian and ubuntu have already.

  2. […] Enable automatic security update in Debian/Ubuntu […]

  3. I suggest adding a new file with a higher lexicographically order instead. Ie. 89-my-apt-settings and put your modifications there. That way, you know you’ll know future upgrades will have sane Debian-given defaults while still using your settings.

    Also, see http://askubuntu.com/questions/254137/etc-apt-apt-conf-d-priority-overrule-configuration-file

Leave a Reply to Jens Rantil Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*