Skip to content

Commit 86f206e

Browse files
authored
Update TrueNAS script
1 parent 235210c commit 86f206e

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

TrueNAS-25.04.sh

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,45 @@ unpriv(){
2424
sudo -u nobody "$@"
2525
}
2626

27+
# Compliance
28+
systemctl mask debug-shell.service
29+
30+
# Setting umask to 077
31+
umask 077
32+
sudo sed -i 's/^UMASK.*/UMASK 077/g' /etc/login.defs
33+
sudo sed -i 's/^HOME_MODE/#HOME_MODE/g' /etc/login.defs
34+
sudo sed -i 's/umask 022/umask 077/g' /etc/bashrc
35+
2736
# Setup NTS
2837
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/refs/heads/main/etc/chrony/conf.d/10-custom.conf | tee /etc/chrony/conf.d/10-custom.conf > /dev/null
38+
chmod 644 /etc/chrony.conf
2939
systemctl restart chronyd
3040

31-
# Configure sysctl
32-
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/sysctl.d/99-server.conf | tee /etc/sysctl.d/99-server.conf > /dev/null
33-
sysctl -p
41+
# Harden SSH
42+
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/ssh/sshd_config.d/10-custom.conf | sudo tee /etc/ssh/sshd_config.d/10-custom.conf > /dev/null
43+
sudo chmod 644 /etc/ssh/sshd_config.d/10-custom.conf
44+
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/ssh/ssh_config.d/10-custom.conf | sudo tee /etc/ssh/ssh_config.d/10-custom.conf > /dev/null
45+
sudo chmod 644 /etc/ssh/ssh_config.d/10-custom.conf
46+
sudo mkdir -p /etc/systemd/system/sshd.service.d/
47+
sudo chmod 755 /etc/systemd/system/sshd.service.d/
48+
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/systemd/system/sshd.service.d/override.conf | sudo tee /etc/systemd/system/sshd.service.d/override.conf > /dev/null
49+
sudo systemctl daemon-reload
50+
sudo systemctl restart sshd
51+
52+
# Rebuild initramfs
53+
update-initramfs -u
54+
55+
# Kernel hardening
56+
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/modprobe.d/server-blacklist.conf | sudo tee /etc/modprobe.d/server-blacklist.conf > /dev/null
57+
sudo chmod 644 /etc/modprobe.d/server-blacklist.conf
58+
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/sysctl.d/99-server.conf | sudo tee /etc/sysctl.d/99-server.conf > /dev/null
59+
sudo chmod 644 /etc/sysctl.d/99-server.conf
60+
sudo dracut -f
61+
sudo sysctl -p
62+
63+
# Disable coredump
64+
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/security/limits.d/30-disable-coredump.conf | sudo tee /etc/security/limits.d/30-disable-coredump.conf > /dev/null
65+
sudo chmod 644 /etc/security/limits.d/30-disable-coredump.conf
66+
sudo mkdir -p /etc/systemd/coredump.conf.d
67+
unpriv curl -s https://raw.githubusercontent.com/Metropolis-nexus/Common-Files/main/etc/systemd/coredump.conf.d/disable.conf | sudo tee /etc/systemd/coredump.conf.d/disable.conf > /dev/null
68+
sudo chmod 644 /etc/systemd/coredump.conf.d/disable.conf

0 commit comments

Comments
 (0)