2024-06-26 02:42:21 -04:00
|
|
|
#!/bin/sh
|
2022-07-26 18:09:49 -04:00
|
|
|
|
2024-04-28 16:57:34 -04:00
|
|
|
# Copyright (C) 2022-2024 Thien Tran
|
2023-09-27 03:58:33 -04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2024-07-02 19:52:42 -04:00
|
|
|
set -e
|
|
|
|
|
2024-05-17 01:47:39 -04:00
|
|
|
unpriv(){
|
|
|
|
sudo -u nobody "$@"
|
|
|
|
}
|
|
|
|
|
2024-04-28 16:57:34 -04:00
|
|
|
# Compliance
|
|
|
|
systemctl mask debug-shell.service
|
|
|
|
systemctl mask kdump.service
|
2022-07-26 18:09:49 -04:00
|
|
|
|
2024-04-28 16:57:34 -04:00
|
|
|
# Setting umask to 077
|
|
|
|
umask 077
|
2024-05-29 15:49:37 -04:00
|
|
|
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/^USERGROUPS_ENAB.*/USERGROUPS_ENAB no/g' /etc/login.defs
|
|
|
|
sudo sed -i 's/umask 022/umask 077/g' /etc/bashrc
|
|
|
|
|
|
|
|
# Make home directory private
|
|
|
|
sudo chmod 700 /home/*
|
2023-01-18 08:52:35 -05:00
|
|
|
|
2024-04-28 16:57:34 -04:00
|
|
|
# Disable timesyncd
|
|
|
|
systemctl disable --now systemd-timesyncd
|
|
|
|
systemctl mask systemd-timesyncd
|
|
|
|
|
2024-05-17 01:36:29 -04:00
|
|
|
# Harden SSH
|
2024-07-02 20:37:34 -04:00
|
|
|
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
|
2024-05-17 01:36:29 -04:00
|
|
|
chmod 644 /etc/ssh/ssh_config.d/10-custom.conf
|
|
|
|
|
2024-04-28 16:57:34 -04:00
|
|
|
# Security kernel settings
|
2024-07-02 20:37:34 -04:00
|
|
|
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
|
2024-04-28 16:57:34 -04:00
|
|
|
# Dracut doesn't seem to work - need to investigate
|
|
|
|
# dracut -f
|
2024-07-02 20:37:34 -04:00
|
|
|
sudo sysctl -p
|
2024-04-28 16:57:34 -04:00
|
|
|
|
2024-05-17 01:36:29 -04:00
|
|
|
# Setup ZRAM
|
2024-07-02 20:37:34 -04:00
|
|
|
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
|
2024-04-28 17:16:43 -04:00
|
|
|
|
|
|
|
# Setup hardened_malloc
|
2024-07-02 20:39:47 -04:00
|
|
|
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
|