mirror of
https://github.com/tommytran732/Linux-Setup-Scripts
synced 2024-11-22 17:41:32 -05:00
Compare commits
No commits in common. "2f5d07bc514e135f78271ab40b99532be420fd24" and "0c8ae2fa244e675d9b73e863493a55d708c1af16" have entirely different histories.
2f5d07bc51
...
0c8ae2fa24
@ -77,50 +77,8 @@ sudo update-initramfs -u
|
||||
# Security limit
|
||||
echo '* hard core 0' | tee -a /etc/security/limits.conf
|
||||
|
||||
# Setup tuned
|
||||
sudo dnf install tuned -y
|
||||
sudo tuned-adm profile virtual-guest
|
||||
|
||||
# Enable fstrim.timer
|
||||
sudo systemctl enable --now fstrim.timer
|
||||
|
||||
### Differentiating bare metal and virtual installs
|
||||
|
||||
# Installing tuned first here because virt-what is 1 of its dependencies anyways
|
||||
sudo apt install tuned -y
|
||||
|
||||
virt_type=$(virt-what)
|
||||
if [ "$virt_type" = "" ]; then
|
||||
output 'Virtualization: Bare Metal.'
|
||||
elif [ "$virt_type" = 'openvz lxc' ]; then
|
||||
output 'Virtualization: OpenVZ 7.'
|
||||
elif [ "$virt_type" = 'xen xen-hvm' ]; then
|
||||
output 'Virtualization: Xen-HVM.'
|
||||
elif [ "$virt_type" = 'xen xen-hvm aws' ]; then
|
||||
output 'Virtualization: Xen-HVM on AWS.'
|
||||
else
|
||||
output "Virtualization: $virt_type."
|
||||
fi
|
||||
|
||||
# Setup tuned
|
||||
if [ "$virt_type" = "" ]; then
|
||||
sudo tuned-adm profile latency-performance
|
||||
else
|
||||
sudo tuned-adm profile virtual-guest
|
||||
fi
|
||||
|
||||
# Setup fwupd
|
||||
if [ "$virt_type" = '' ]; then
|
||||
sudo apt install fwupd -y
|
||||
echo 'UriSchemes=file;https' | sudo tee -a /etc/fwupd/fwupd.conf
|
||||
sudo systemctl restart fwupd
|
||||
mkdir -p /etc/systemd/system/fwupd-refresh.service.d
|
||||
unpriv curl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/system/fwupd-refresh.service.d/override.conf | sudo tee /etc/systemd/system/fwupd-refresh.service.d/override.conf
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now fwupd-refresh.timer
|
||||
fi
|
||||
|
||||
# Setup unbound
|
||||
|
||||
sudo apt instal unbound resolvconf -y
|
||||
|
||||
echo 'server:
|
||||
@ -190,5 +148,11 @@ BindPaths=-/dev/log:@UNBOUND_CHROOT_DIR@/dev/log' | sudo tee /etc/systemd/system
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart unbound
|
||||
sudo systemctl disable systemd-resolved
|
||||
sudo reboot
|
||||
sudo systemctl disable --now systemd-resolved
|
||||
|
||||
# Setup tuned
|
||||
sudo dnf install tuned -y
|
||||
sudo tuned-adm profile virtual-guest
|
||||
|
||||
# Enable fstrim.timer
|
||||
sudo systemctl enable --now fstrim.timer
|
||||
|
@ -15,6 +15,7 @@
|
||||
# the License.
|
||||
|
||||
#Meant to be run on Ubuntu Pro Minimal
|
||||
#The script assumes you already have Ubuntu Pro activated
|
||||
|
||||
output(){
|
||||
echo -e '\e[36m'"$1"'\e[0m';
|
||||
@ -28,17 +29,13 @@ unpriv(){
|
||||
sudo systemctl mask ctrl-alt-del.target
|
||||
sudo systemctl mask debug-shell.service
|
||||
echo 'CtrlAltDelBurstAction=none' | sudo tee -a /etc/systemd/system.conf
|
||||
echo 'Authorized uses only. All activity may be monitored and reported.' | sudo tee /etc/issue
|
||||
echo 'Authorized uses only. All activity may be monitored and reported.' | sudo tee /etc/issue.net
|
||||
|
||||
#USG CIS Server 2 Breaks Unbound right now.
|
||||
#sudo ua enable usg
|
||||
sudo ua enable usg
|
||||
sudo apt update -y
|
||||
sudo apt full-upgrade -y
|
||||
sudo apt install -y curl
|
||||
#sudo apt install -y usg curl libpam-pwquality
|
||||
#sudo apt autoremove -y
|
||||
#sudo usg fix cis_level2_server
|
||||
sudo apt install -y usg curl libpam-pwquality
|
||||
sudo apt autoremove -y
|
||||
sudo usg fix cis_level2_server
|
||||
|
||||
# Make home directory private
|
||||
chmod 700 /home/*
|
||||
@ -57,7 +54,7 @@ sudo systemctl restart chronyd
|
||||
sudo apt purge -y ufw
|
||||
sudo snap install ufw
|
||||
sudo ufw enable
|
||||
sudo ufw allow SSH
|
||||
sudo ufw allow OpenSSH
|
||||
|
||||
# Harden SSH
|
||||
echo 'GSSAPIAuthentication no
|
||||
@ -70,71 +67,6 @@ unpriv curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/sys
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart sshd
|
||||
|
||||
# Kernel hardening
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/modprobe.d/30_security-misc.conf | sudo tee /etc/modprobe.d/30_security-misc.conf
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/usr/lib/sysctl.d/990-security-misc.conf | sudo tee /etc/sysctl.d/990-security-misc.conf
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/usr/lib/sysctl.d/30_silent-kernel-printk.conf | sudo tee /etc/sysctl.d/30_silent-kernel-printk.conf
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/usr/lib/sysctl.d/30_security-misc_kexec-disable.conf | sudo tee /etc/sysctl.d/30_security-misc_kexec-disable.conf
|
||||
sudo sed -i 's/kernel.yama.ptrace_scope=2/kernel.yama.ptrace_scope=3/g' /etc/sysctl.d/990-security-misc.conf
|
||||
sudo sed -i 's/net.ipv4.icmp_echo_ignore_all=1/net.ipv4.icmp_echo_ignore_all=0/g' /etc/sysctl.d/990-security-misc.conf
|
||||
sudo sed -i 's/net.ipv6.icmp.echo_ignore_all=1/net.ipv6.icmp.echo_ignore_all=0/g' /etc/sysctl.d/990-security-misc.conf
|
||||
sudo sysctl -p
|
||||
|
||||
# Rebuild initramfs
|
||||
sudo update-initramfs -u
|
||||
|
||||
# Disable telemetry
|
||||
sudo systemctl stop apport.service
|
||||
sudo systemctl disable apport.service
|
||||
sudo systemctl mask apport.service
|
||||
|
||||
#Setup fwupd
|
||||
sudo apt install fwupd -y
|
||||
mkdir -p /etc/systemd/system/fwupd-refresh.service.d
|
||||
echo '[Service]
|
||||
ExecStart=/usr/bin/fwupdmgr update' | tee /etc/systemd/system/fwupd-refresh.service.d/override.conf
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now fwupd-refresh.timer
|
||||
|
||||
# Enable fstrim.timer
|
||||
sudo systemctl enable --now fstrim.timer
|
||||
|
||||
### Differentiating bare metal and virtual installs
|
||||
|
||||
# Installing tuned first here because virt-what is 1 of its dependencies anyways
|
||||
sudo apt install tuned -y
|
||||
|
||||
virt_type=$(virt-what)
|
||||
if [ "$virt_type" = "" ]; then
|
||||
output 'Virtualization: Bare Metal.'
|
||||
elif [ "$virt_type" = 'openvz lxc' ]; then
|
||||
output 'Virtualization: OpenVZ 7.'
|
||||
elif [ "$virt_type" = 'xen xen-hvm' ]; then
|
||||
output 'Virtualization: Xen-HVM.'
|
||||
elif [ "$virt_type" = 'xen xen-hvm aws' ]; then
|
||||
output 'Virtualization: Xen-HVM on AWS.'
|
||||
else
|
||||
output "Virtualization: $virt_type."
|
||||
fi
|
||||
|
||||
# Setup tuned
|
||||
if [ "$virt_type" = "" ]; then
|
||||
sudo tuned-adm profile latency-performance
|
||||
else
|
||||
sudo tuned-adm profile virtual-guest
|
||||
fi
|
||||
|
||||
# Setup fwupd
|
||||
if [ "$virt_type" = '' ]; then
|
||||
sudo apt install fwupd -y
|
||||
echo 'UriSchemes=file;https' | sudo tee -a /etc/fwupd/fwupd.conf
|
||||
sudo systemctl restart fwupd
|
||||
mkdir -p /etc/systemd/system/fwupd-refresh.service.d
|
||||
unpriv curl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/system/fwupd-refresh.service.d/override.conf | sudo tee /etc/systemd/system/fwupd-refresh.service.d/override.conf
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now fwupd-refresh.timer
|
||||
fi
|
||||
|
||||
# Setup unbound
|
||||
|
||||
sudo apt install -y unbound
|
||||
@ -206,6 +138,72 @@ BindPaths=-/dev/log:@UNBOUND_CHROOT_DIR@/dev/log' | sudo tee /etc/systemd/system
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart unbound
|
||||
sudo systemctl disable systemd-resolved
|
||||
sudo systemctl disable --now systemd-resolved
|
||||
|
||||
sudo reboot
|
||||
# Kernel hardening
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/modprobe.d/30_security-misc.conf | sudo tee /etc/modprobe.d/30_security-misc.conf
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/usr/lib/sysctl.d/990-security-misc.conf | sudo tee /etc/sysctl.d/990-security-misc.conf
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/usr/lib/sysctl.d/30_silent-kernel-printk.conf | sudo tee /etc/sysctl.d/30_silent-kernel-printk.conf
|
||||
unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/usr/lib/sysctl.d/30_security-misc_kexec-disable.conf | sudo tee /etc/sysctl.d/30_security-misc_kexec-disable.conf
|
||||
sudo sed -i 's/kernel.yama.ptrace_scope=2/kernel.yama.ptrace_scope=3/g' /etc/sysctl.d/990-security-misc.conf
|
||||
sudo sed -i 's/net.ipv4.icmp_echo_ignore_all=1/net.ipv4.icmp_echo_ignore_all=0/g' /etc/sysctl.d/990-security-misc.conf
|
||||
sudo sed -i 's/net.ipv6.icmp.echo_ignore_all=1/net.ipv6.icmp.echo_ignore_all=0/g' /etc/sysctl.d/990-security-misc.conf
|
||||
sudo sysctl -p
|
||||
|
||||
# Rebuild initramfs
|
||||
sudo update-initramfs -u
|
||||
|
||||
# Disable telemetry
|
||||
sudo systemctl stop apport.service
|
||||
sudo systemctl disable apport.service
|
||||
sudo systemctl mask apport.service
|
||||
sudo systemctl stop whoopsie.service
|
||||
sudo systemctl disable whoopsie.service
|
||||
sudo systemctl mask whoopsie.service
|
||||
|
||||
#Setup fwupd
|
||||
sudo apt install fwupd -y
|
||||
mkdir -p /etc/systemd/system/fwupd-refresh.service.d
|
||||
echo '[Service]
|
||||
ExecStart=/usr/bin/fwupdmgr update' | tee /etc/systemd/system/fwupd-refresh.service.d/override.conf
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now fwupd-refresh.timer
|
||||
|
||||
# Enable fstrim.timer
|
||||
sudo systemctl enable --now fstrim.timer
|
||||
|
||||
### Differentiating bare metal and virtual installs
|
||||
|
||||
# Installing tuned first here because virt-what is 1 of its dependencies anyways
|
||||
sudo apt install tuned -y
|
||||
|
||||
virt_type=$(virt-what)
|
||||
if [ "$virt_type" = "" ]; then
|
||||
output 'Virtualization: Bare Metal.'
|
||||
elif [ "$virt_type" = 'openvz lxc' ]; then
|
||||
output 'Virtualization: OpenVZ 7.'
|
||||
elif [ "$virt_type" = 'xen xen-hvm' ]; then
|
||||
output 'Virtualization: Xen-HVM.'
|
||||
elif [ "$virt_type" = 'xen xen-hvm aws' ]; then
|
||||
output 'Virtualization: Xen-HVM on AWS.'
|
||||
else
|
||||
output "Virtualization: $virt_type."
|
||||
fi
|
||||
|
||||
# Setup tuned
|
||||
if [ "$virt_type" = "" ]; then
|
||||
sudo tuned-adm profile latency-performance
|
||||
else
|
||||
sudo tuned-adm profile virtual-guest
|
||||
fi
|
||||
|
||||
# Setup fwupd
|
||||
if [ "$virt_type" = '' ]; then
|
||||
sudo apt install fwupd -y
|
||||
echo 'UriSchemes=file;https' | sudo tee -a /etc/fwupd/fwupd.conf
|
||||
sudo systemctl restart fwupd
|
||||
mkdir -p /etc/systemd/system/fwupd-refresh.service.d
|
||||
unpriv curl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/system/fwupd-refresh.service.d/override.conf | sudo tee /etc/systemd/system/fwupd-refresh.service.d/override.conf
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now fwupd-refresh.timer
|
||||
fi
|
Loading…
Reference in New Issue
Block a user