Fevzi Daş

Kişisel Web Sayfası

Ubuntu 16.04'te Güvenlik Güncelleştirmelerini Otomatik Yaptırmak

Not: Bu sayfada ve web sitesinin tamamında yer alan bilgiler bilgi amaçlı olup oluşabilecek sorun veya istenmeyen durumlardan dolayı hiç bir sorumluluk kabul edilmez.

### Öncelikle bu işlemi yapacak paketi aşağıdaki komut ile indiriyoruz.

sudo apt install unattended-upgrade

### Servisi kontrol ediyoruz.

sudo systemctl status unattended-upgrades

● unattended-upgrades.service - Unattended Upgrades Shutdown

Loaded: loaded (/lib/systemd/system/unattended-upgrades.service; enabled; vendor preset: enabled)

Active: active (running) since ***

### Daha sonra sadece güvenlik güncelleştirmelerinin yapılmasını sağlayan ayarları yapıyoruz. Tabi bunun için öncelikle ilgili dosyanın yedeğini almakta fayda var.

sudo cp /etc/apt/apt.conf.d/50unattended-upgrades /etc/apt/apt.conf.d/50unattended-upgrades.backup

### Dosyayı açıyoruz.

sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

### Dosyanın ilgili bölümlerini aşağıdaki gibi ayarlıyoruz.

// Automatically upgrade packages from these (origin:archive) pairs

Unattended-Upgrade::Allowed-Origins {

"${distro_id}:${distro_codename}";

"${distro_id}:${distro_codename}-security";

// Extended Security Maintenance; doesn't necessarily exist for

// every release and this system may not have it installed, but if

// available, the policy for updates is such that unattended-upgrades

// should also install from here by default.

"${distro_id}ESMApps:${distro_codename}-apps-security";

"${distro_id}ESM:${distro_codename}-infra-security";

// "${distro_id}:${distro_codename}-updates";

// "${distro_id}:${distro_codename}-proposed";

// "${distro_id}:${distro_codename}-backports";

};


// List of packages to not update (regexp are supported)

Unattended-Upgrade::Package-Blacklist {

// "vim";

// "libc6";

// "libc6-dev";

// "libc6-i686";

};


// This option allows you to control if on a unclean dpkg exit

// unattended-upgrades will automatically run

// dpkg --force-confold --configure -a

// The default is true, to ensure updates keep getting installed

//Unattended-Upgrade::AutoFixInterruptedDpkg "false";


// Split the upgrade into the smallest possible chunks so that

// they can be interrupted with SIGUSR1. This makes the upgrade

// a bit slower but it has the benefit that shutdown while a upgrade

// is running is possible (with a small delay)

//Unattended-Upgrade::MinimalSteps "true";


// Install all unattended-upgrades when the machine is shuting down

// instead of doing it in the background while the machine is running

// This will (obviously) make shutdown slower

//Unattended-Upgrade::InstallOnShutdown "true";


// 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. A package that provides

// 'mailx' must be installed. E.g. "user@example.com"

Unattended-Upgrade::Mail "fev****@gmail.com";


// Set this value to "true" to get emails only on errors. Default

// is to always send a mail if Unattended-Upgrade::Mail is set


### Daha sonra /etc/apt/apt.conf.d/10periodic dosyasını aşağıdaki gibi düzenliyoruz. Bu ayarlar , güvenlik güncellemelerinin paket listesini güncellemesine, mevcut yükseltmeleri her gün indirilmesine ve kurmasına ve ayrıca yerel indirme arşivinin her hafta temizlenmesine izin vermektedir. Otomatik güncellemeleri devre dışı bırakmak istiyorsanız, 1 değerini 0 olarak değiştirmeniz yeterlidir.

# vi /etc/apt/apt.conf.d/10periodic

APT::Periodic::Update-Package-Lists "1";

APT::Periodic::Download-Upgradeable-Packages "1";

APT::Periodic::AutocleanInterval "7";

APT::Periodic::Unattended-Upgrade "1";

Bu işleme ait log dosyaları aşağıdaki dosya tutulmaktadır.

/var/log/unattended-upgrades

Otomatik güncelleme aracı aşağıdaki komut ile kaldırılabilir.

sudo apt-get remove unattended-upgrades

Otomatik güncellemeler yalnızca paket depoları tarafından sağlanan hizmetlere uygulanacak ve kaynaktan derlenen hizmetlere uygulanmayacaktır.