From 565ff45b1a57cc81acf161d7b8fbf045b549af18 Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 25 Jan 2023 06:33:56 -0500 Subject: [PATCH] Reorganization Signed-off-by: Tommy --- GCP-Debian-11.sh | 15 ++++++------ Proxmox-7.sh | 19 ++++++++------ RHEL-Server-9.sh | 64 +++++++++++++++++++++++------------------------- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/GCP-Debian-11.sh b/GCP-Debian-11.sh index 9655a5c..012cd8a 100644 --- a/GCP-Debian-11.sh +++ b/GCP-Debian-11.sh @@ -1,5 +1,10 @@ #!/bin/bash +echo 'GSSAPIAuthentication no +VerifyHostKeyDNS yes' | sudo tee /etc/ssh/ssh_config.d/10-custom.conf +sudo sed -i 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/g' /etc/ssh/sshd_config +sudo systemctl restart sshd + sudo find /etc/apt/sources.list.d -type f -exec sudo sed -i 's/http:/https:/g' {} \; sudo apt update @@ -44,6 +49,9 @@ forward-zone: sudo systemctl restart unbound +sudo mkdir -p /etc/systemd/system/sshd.service.d +sudo curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/systemd/system/sshd.service.d/limits.conf -o /etc/systemd/system/sshd.service.d/limits.conf + sudo rm -rf /etc/chrony/chrony.conf sudo curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf -o /etc/chrony/chrony.conf sudo systemctl restart chronyd @@ -54,12 +62,5 @@ sudo sed -i 's/kernel.yama.ptrace_scope=2/kernel.yama.ptrace_scope=3/g' /etc/sys sudo curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/sysctl.d/30_silent-kernel-printk.conf -o /etc/sysctl.d/30_silent-kernel-printk.conf sudo mkdir -p /etc/systemd/system/NetworkManager.service.d sudo curl https://gitlab.com/divested/brace/-/raw/master/brace/usr/lib/systemd/system/NetworkManager.service.d/99-brace.conf -o /etc/systemd/system/NetworkManager.service.d/99-brace.conf -sudo mkdir -p /etc/systemd/system/sshd.service.d -sudo curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/systemd/system/sshd.service.d/limits.conf -o /etc/systemd/system/sshd.service.d/limits.conf - -echo 'GSSAPIAuthentication no -VerifyHostKeyDNS yes' | sudo tee /etc/ssh/ssh_config.d/10-custom.conf echo "* hard core 0" | tee -a /etc/security/limits.conf - -sed -i 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/g' /etc/ssh/sshd_config diff --git a/Proxmox-7.sh b/Proxmox-7.sh index 6eea847..8f1ed33 100644 --- a/Proxmox-7.sh +++ b/Proxmox-7.sh @@ -1,5 +1,12 @@ #!/bin/bash +echo 'GSSAPIAuthentication no +VerifyHostKeyDNS yes' | sudo tee /etc/ssh/ssh_config.d/10-custom.conf +sed -i 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/g' /etc/ssh/sshd_config +mkdir -p /etc/systemd/system/sshd.service.d +curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/systemd/system/sshd.service.d/limits.conf -o /etc/systemd/system/sshd.service.d/limits.conf +systemctl restart sshd + sed -i '1 {s/^/#/}' /etc/apt/sources.list.d/pve-enterprise.list echo 'deb https://deb.debian.org/debian/ bullseye main contrib non-free @@ -17,6 +24,10 @@ apt install -y intel-microcode tuned apparmor-profiles fwupd tuned-adm profile virtual-host +rm -rf /etc/chrony/chrony.conf +curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf -o /etc/chrony/chrony.conf +systemctl restart chronyd + ### This part assumes that you are using systemd-boot echo -e "spectre_v2=on spec_store_bypass_disable=on l1tf=full,force mds=full,nosmt tsx=off tsx_async_abort=full,nosmt kvm.nx_huge_pages=force nosmt=force l1d_flush=on mmio_stale_data=full,nosmt random.trust_bootloader=off random.trust_cpu=off intel_iommu=on amd_iommu=on efi=disable_early_pci_dma iommu.passthrough=0 iommu.strict=1 slab_nomerge init_on_alloc=1 init_on_free=1 pti=on vsyscall=none page_alloc.shuffle=1 randomize_kstack_offset=on extra_latent_entropy debugfs=off $(cat /etc/kernel/cmdline)" > /etc/kernel/cmdline proxmox-boot-tool refresh @@ -28,11 +39,6 @@ sed -i 's/kernel.yama.ptrace_scope=2/kernel.yama.ptrace_scope=3/g' /etc/sysctl.d curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/sysctl.d/30_silent-kernel-printk.conf -o /etc/sysctl.d/30_silent-kernel-printk.conf mkdir -p /etc/systemd/system/NetworkManager.service.d curl https://gitlab.com/divested/brace/-/raw/master/brace/usr/lib/systemd/system/NetworkManager.service.d/99-brace.conf -o /etc/systemd/system/NetworkManager.service.d/99-brace.conf -mkdir -p /etc/systemd/system/sshd.service.d -curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/systemd/system/sshd.service.d/limits.conf -o /etc/systemd/system/sshd.service.d/limits.conf - -rm -rf /etc/chrony/chrony.conf -curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf -o /etc/chrony/chrony.conf echo "* hard core 0" | tee -a /etc/security/limits.conf @@ -52,6 +58,3 @@ systemctl enable --now fwupd-refresh.timer bash <(curl -s https://raw.githubusercontent.com/Weilbyte/PVEDiscordDark/master/PVEDiscordDark.sh ) install systemctl restart pveproxy.service - -echo "GSSAPIAuthentication no" > /etc/ssh/ssh_config.d/10-custom.conf -echo "VerifyHostKeyDNS yes" >> /etc/ssh/ssh_config.d/10-custom.conf diff --git a/RHEL-Server-9.sh b/RHEL-Server-9.sh index ea8afa3..2ac088d 100644 --- a/RHEL-Server-9.sh +++ b/RHEL-Server-9.sh @@ -2,42 +2,16 @@ #Assuming that you are using ANSSI-BP-028 mkdir -p /etc/ssh/ssh_config.d /etc/ssh/sshd_config.d -echo "GSSAPIAuthentication no" | sudo tee -a /etc/ssh/ssh_config.d/10-custom.conf -echo "X11Forwarding no -GSSAPIAuthentication no" | sudo tee -a /etc/ssh/sshd_config.d/10-custom.conf -echo "PasswordAuthentication no" | sudo tee /etc/ssh/sshd_config.d/40-disable-passwords.conf - -sudo dnf install tuned yara -y -sudo tuned-adm profile virtual-guest - -sudo insights-client --collector malware-detection -sudo sed -i 's/test_scan: true/test_scan: false/' /etc/insights-client/malware-detection-config.yml - -sudo curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/modprobe.d/30_security-misc.conf -o /etc/modprobe.d/30_security-misc.conf -sudo curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/sysctl.d/30_security-misc.conf -o /etc/sysctl.d/30_security-misc.conf -sudo sed -i 's/kernel.yama.ptrace_scope=2/kernel.yama.ptrace_scope=3/g' /etc/sysctl.d/30_security-misc.conf -sudo curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/sysctl.d/30_silent-kernel-printk.conf -o /etc/sysctl.d/30_silent-kernel-printk.conf -sudo sysctl -p - -sudo curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf -o /etc/chrony.conf -sudo systemctl restart chronyd - -sudo mkdir -p /etc/systemd/system/NetworkManager.service.d -sudo curl https://gitlab.com/divested/brace/-/raw/master/brace/usr/lib/systemd/system/NetworkManager.service.d/99-brace.conf -o /etc/systemd/system/NetworkManager.service.d/99-brace.conf -sudo systemctl restart NetworkManager - -sudo mkdir -p /etc/systemd/system/irqbalance.service.d -sudo curl https://gitlab.com/divested/brace/-/raw/master/brace/usr/lib/systemd/system/irqbalance.service.d/99-brace.conf -o /etc/systemd/system/irqbalance.service.d/99-brace.conf -sudo systemctl restart irqbalance - -sudo mkdir -p /etc/systemd/system/sshd.service.d -sudo curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/systemd/system/sshd.service.d/limits.conf -o /etc/systemd/system/sshd.service.d/limits.conf +echo 'GSSAPIAuthentication no +VerifyHostKeyDNS yes' | sudo tee /etc/ssh/ssh_config.d/10-custom.conf +echo 'X11Forwarding no +GSSAPIAuthentication no +PasswordAuthentication no' | sudo tee /etc/ssh/sshd_config.d/10-custom.conf sudo systemctl restart sshd -echo "GSSAPIAuthentication no" | sudo tee /etc/ssh/ssh_config.d/10-custom.conf -echo "VerifyHostKeyDNS yes" | sudo tee -a /etc/ssh/ssh_config.d/10-custom.conf +sudo dnf install tuned unbound yara -y +sudo tuned-adm profile virtual-guest -sudo dnf install unbound echo 'server: chroot: "" @@ -98,3 +72,27 @@ RestrictNamespaces=yes LockPersonality=yes' | sudo tee /etc/systemd/system/unbound.service.d/override.conf sudo systemctl enable --now unbound + +sudo mkdir -p /etc/systemd/system/sshd.service.d +sudo curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/systemd/system/sshd.service.d/limits.conf -o /etc/systemd/system/sshd.service.d/limits.conf +sudo systemctl restart sshd + +sudo curl https://raw.githubusercontent.com/GrapheneOS/infrastructure/main/chrony.conf -o /etc/chrony.conf +sudo systemctl restart chronyd + +sudo insights-client --collector malware-detection +sudo sed -i 's/test_scan: true/test_scan: false/' /etc/insights-client/malware-detection-config.yml + +sudo curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/modprobe.d/30_security-misc.conf -o /etc/modprobe.d/30_security-misc.conf +sudo curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/sysctl.d/30_security-misc.conf -o /etc/sysctl.d/30_security-misc.conf +sudo sed -i 's/kernel.yama.ptrace_scope=2/kernel.yama.ptrace_scope=3/g' /etc/sysctl.d/30_security-misc.conf +sudo curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/etc/sysctl.d/30_silent-kernel-printk.conf -o /etc/sysctl.d/30_silent-kernel-printk.conf +sudo sysctl -p + +sudo mkdir -p /etc/systemd/system/NetworkManager.service.d +sudo curl https://gitlab.com/divested/brace/-/raw/master/brace/usr/lib/systemd/system/NetworkManager.service.d/99-brace.conf -o /etc/systemd/system/NetworkManager.service.d/99-brace.conf +sudo systemctl restart NetworkManager + +sudo mkdir -p /etc/systemd/system/irqbalance.service.d +sudo curl https://gitlab.com/divested/brace/-/raw/master/brace/usr/lib/systemd/system/irqbalance.service.d/99-brace.conf -o /etc/systemd/system/irqbalance.service.d/99-brace.conf +sudo systemctl restart irqbalance