2024-10-08 18:13:50 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Copyright (C) 2022-2024 mustard
|
|
|
|
#
|
|
|
|
# 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 -o pipefail
|
|
|
|
|
|
|
|
unpriv(){
|
|
|
|
sudo -u nobody "${@}"
|
|
|
|
}
|
|
|
|
|
|
|
|
dl() {
|
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 "${1}" | sudo tee "${2}" > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
# Compliance
|
|
|
|
sudo systemctl mask debug-shell.service
|
|
|
|
sudo 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/*
|
|
|
|
|
|
|
|
# Harden SSH
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/ssh/ssh_config.d/10-custom.conf /etc/ssh/ssh_config.d/10-custom.conf
|
|
|
|
sudo chmod 644 /etc/ssh/ssh_config.d/10-custom.conf
|
|
|
|
|
|
|
|
# Security kernel settings
|
|
|
|
dl https://raw.githubusercontent.com/secureblue/secureblue/live/files/system/etc/modprobe.d/blacklist.conf /etc/modprobe.d/workstation-blacklist.conf
|
|
|
|
|
|
|
|
sudo sed -i 's/^install hfsplus \/bin\/false/# install hfsplus \/bin\/false/' /etc/modprobe.d/workstation-blacklist.conf
|
|
|
|
sudo chmod 644 /etc/modprobe.d/workstation-blacklist.conf
|
|
|
|
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/sysctl.d/99-workstation.conf /etc/sysctl.d/99-workstation.conf
|
|
|
|
sudo chmod 644 /etc/sysctl.d/99-workstation.conf
|
|
|
|
# Dracut doesn't seem to work - need to investigate
|
|
|
|
# dracut -f
|
|
|
|
sudo sysctl -p
|
|
|
|
|
|
|
|
# Disable coredump
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/security/limits.d/30-disable-coredump.conf /etc/security/limits.d/30-disable-coredump.conf
|
|
|
|
sudo chmod 644 /etc/security/limits.d/30-disable-coredump.conf
|
|
|
|
sudo mkdir -p /etc/systemd/coredump.conf.d
|
|
|
|
sudo chmod 755 /etc/systemd/coredump.conf.d
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/coredump.conf.d/disable.conf /etc/systemd/coredump.conf.d/disable.conf
|
|
|
|
sudo chmod 644 /etc/systemd/coredump.conf.d/disable.conf
|
|
|
|
|
|
|
|
# Setup dconf
|
|
|
|
umask 022
|
|
|
|
mkdir -p /etc/dconf/db/local.d/locks
|
|
|
|
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/locks/automount-disable /etc/dconf/db/local.d/locks/automount-disable
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/locks/privacy /etc/dconf/db/local.d/locks/privacy
|
|
|
|
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/adw-gtk3-dark /etc/dconf/db/local.d/adw-gtk3-dark
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/automount-disable /etc/dconf/db/local.d/automount-disable
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/prefer-dark /etc/dconf/db/local.d/prefer-dark
|
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/privacy /etc/dconf/db/local.d/privacy
|
|
|
|
|
|
|
|
sudo dconf update
|
|
|
|
umask 077
|
|
|
|
|
|
|
|
# Setup ZRAM
|
2024-10-08 18:41:41 +02:00
|
|
|
dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/zram-generator.conf /etc/systemd/zram-generator.conf
|