mirror of
https://github.com/tommytran732/QubesOS-Scripts
synced 2024-11-13 22:01:34 -05:00
60 lines
2.3 KiB
Bash
60 lines
2.3 KiB
Bash
#!/bin/sh
|
|
|
|
# Copyright (C) 2022-2024 Thien Tran
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
# use this file except in compliance with the License. You may obtain a copy of
|
|
# the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations under
|
|
# the License.
|
|
|
|
set -eu
|
|
|
|
unpriv(){
|
|
sudo -u nobody "$@"
|
|
}
|
|
|
|
# Compliance
|
|
systemctl mask debug-shell.service
|
|
systemctl mask kdump.service
|
|
|
|
# Setting umask to 077
|
|
umask 077
|
|
sudo sed -i 's/^UMASK.*/UMASK 077/g' /etc/login.defs
|
|
sudo sed -i 's/^HOME_MODE/#HOME_MODE/g' /etc/login.defs
|
|
sudo sed -i 's/umask 022/umask 077/g' /etc/bashrc
|
|
|
|
# Make home directory private
|
|
sudo chmod 700 /home/*
|
|
|
|
# Disable timesyncd
|
|
systemctl disable --now systemd-timesyncd
|
|
systemctl mask systemd-timesyncd
|
|
|
|
# Harden SSH
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/ssh/ssh_config.d/10-custom.conf | tee /etc/ssh/ssh_config.d/10-custom.conf > /dev/null
|
|
chmod 644 /etc/ssh/ssh_config.d/10-custom.conf
|
|
|
|
# Security kernel settings
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/secureblue/secureblue/live/config/files/usr/etc/modprobe.d/blacklist.conf | sudo tee /etc/modprobe.d/workstation-blacklist.conf > /dev/null
|
|
sudo chmod 644 /etc/modprobe.d/workstation-blacklist.conf
|
|
unpriv curl -s --proxy https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/sysctl.d/99-workstation.conf | sudo tee /etc/sysctl.d/99-workstation.conf > /dev/null
|
|
sudo chmod 644 /etc/sysctl.d/30_security-misc_kexec-disable.conf
|
|
# Dracut doesn't seem to work - need to investigate
|
|
# dracut -f
|
|
sudo sysctl -p
|
|
|
|
# Setup ZRAM
|
|
unpriv curl --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/zram-generator.conf | sudo tee /etc/systemd/zram-generator.conf > /dev/null
|
|
|
|
# Setup hardened_malloc
|
|
sudo dnf copr enable secureblue/hardened_malloc -y
|
|
sudo dnf install -y hardened_malloc
|
|
echo 'libhardened_malloc.so' | sudo tee /etc/ld.so.preload
|
|
sudo chmod 644 /etc/ld.so.preload |