Automatic updates in kali

Automatic updates in kali (and other apt based distros). There are a ton of ways to do automatic updates in kali linux (though this will work on debian, ubuntu, proxmox and any other apt-based system):

1) unattended-upgrades
2) a cron script
3) cron-apt

This post will go through the various ways to update your system in the background.

Automatic updates in kali with unattended-upgrades

unattended-upgrades is a script available as a deb package and can be in stalled with a couple of lines:


apt-get install unattended-upgrades
dpkg-reconfigure --priority=low unattended-upgrades

You’ll need to answer the questions that follow.
The cusrse dialog will create two files:


/etc/apt/apt.conf.d/20auto-upgrades
/etc/apt/apt.conf.d/50unattended-upgrades

Essentially, at this point you are done. This is the system thatI prefer to use on deb based systems.

cron

A simple kali linux automatic update script can be used to do automatic updates in kali. This little script (when run with cron) will keep your kali up to date. Source: https://gist.github.com/RaDeleon/37e38d5a0116843a32f3

Create a new file (eg in /usr/local/bin/update-kali), and add the following


#!/bin/sh
apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
apt-get autoclean -y && apt-get clean -y
apt-get autoremove

make the script executable


chmod +X /usr/local/bin/update-kali

next, create a cron job to run the script at an interval (eg run it once a day)


crontab -e

add in the following code to the ctontab file (the example runs the script at 3am, every day)


0	3	*	*	*	/usr/local/bin/update-kali

One disadvantage is that apt sometimes asks for user input when modifying a config file – if this happens, then the cron script can fail – so it needs to be checked from time to time.

Automatic updates in kali with cron-apt

https://debian-administration.org/article/162/A_short_introduction_to_cron-apt


    apt-get install cron-apt

I haven’t installed cron-apt on my kali systems, but the manual explains it pretty well – I’ve included it here for completeness, incase you want to use it – bacically it downloads any available packages, but doesnt install them.

Configuration can be done by editing /etc/cron-apt/config and by adding
rules to /etc/cron-apt/action.d/ The variables that you can set in
/etc/cron-apt/config is documented in the configuration example in
/usr/share/doc/cron-apt/examples/config

You have to manually install the updates that have been downloaded, with the regular apt-get upgrade and apt-get dist-upgrade commands – they will run faster as no packages have to be downloaded, but if you are running these commands manually on a regular basis (eg every couple of days) then you wont notice any difference.

Sources:
https://help.ubuntu.com/community/AutomaticSecurityUpdates
man apt-get
man apt-cron
Intro to cron-apt

Leave a Reply