-
Notifications
You must be signed in to change notification settings - Fork 0
/
secure-debian-ubuntu.sh
52 lines (40 loc) · 1.68 KB
/
secure-debian-ubuntu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Some snippets to secure and harden a system:
# Optional Lynis install via git:
#cd /opt
#git clone --depth 1 https://github.com/CISOfy/lynis
#./lynis audit system
# antivirus
apt install clamav clamav-daemon -y
systemctl stop clamav-freshclam
freshclam
systemctl start clamav-freshclam
apt install fail2ban git debsums chkrootkit sysstat libpam-tmpdir needrestart debsecan apt-listbugs arpwatch -y
# randomness/entropy
apt install rng-tools-debian haveged -y
# install lynis
# see lynis CIS apt repo...
curl -fsSL https://packages.cisofy.com/keys/cisofy-software-public.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/cisofy-software-public.gpg
echo "deb [arch=amd64,arm64 signed-by=/etc/apt/trusted.gpg.d/cisofy-software-public.gpg] https://packages.cisofy.com/community/lynis/deb/ stable main" | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list
apt install apt-transport-https
echo 'Acquire::Languages "none";' | sudo tee /etc/apt/apt.conf.d/99disable-translations
echo "deb https://packages.cisofy.com/community/lynis/deb/ stable main" | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list
apt update&&apt install lynis -y
touch /etc/apt/preferences.d/lynis
cat <<EOF > /etc/apt/preferences.d/lynis
Package: lynis
Pin: origin packages.cisofy.com
Pin-Priority: 600
EOF
# automation
# install ansible (if reqired)
# ensure jails don't get over-written
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# unpurged packages:
dpkg --list | grep ^rc | awk '{ print $2; }'
# purge:
apt purge `dpkg --list | grep ^rc | awk '{ print $2; }'`
# automatic updates:
apt install unattended-upgrades -y
systemctl start unattended-upgrades
systemctl enable unattended-upgrades
unattended-upgrades --dry-run --debug