2024-06-26 02:42:21 -04:00
|
|
|
#!/bin/sh
|
2024-05-17 05:54:50 -04:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
2024-07-03 05:19:13 -04:00
|
|
|
set -e
|
|
|
|
|
2024-05-17 05:54:50 -04:00
|
|
|
unpriv(){
|
|
|
|
sudo -u nobody "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Compliance
|
|
|
|
sudo systemctl mask debug-shell.service
|
|
|
|
|
|
|
|
# Setting umask to 077
|
2024-05-29 15:49:37 -04:00
|
|
|
# Does not actually work for some reason - need to check
|
2024-05-17 05:54:50 -04:00
|
|
|
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/*
|
2024-05-17 05:54:50 -04:00
|
|
|
|
|
|
|
# Harden SSH
|
2024-07-03 05:19:13 -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 | sudo tee /etc/ssh/ssh_config.d/10-custom.conf > /dev/null
|
2024-05-17 05:54:50 -04:00
|
|
|
sudo chmod 644 /etc/ssh/ssh_config.d/10-custom.conf
|
|
|
|
|
|
|
|
# Disable coredump
|
2024-07-03 05:19:13 -04:00
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/security/limits.d/30-disable-coredump.conf | sudo tee /etc/security/limits.d/30-disable-coredump.conf > /dev/null
|
2024-05-17 05:54:50 -04:00
|
|
|
|
|
|
|
# Setup dconf
|
|
|
|
umask 022
|
|
|
|
mkdir -p /etc/dconf/db/local.d/locks
|
|
|
|
|
2024-07-03 05:19:13 -04:00
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/locks/automount-disable | sudo tee /etc/dconf/db/local.d/locks/automount-disable > /dev/null
|
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/locks/privacy | sudo tee /etc/dconf/db/local.d/locks/privacy > /dev/null
|
2024-05-17 05:54:50 -04:00
|
|
|
|
2024-07-03 05:19:13 -04:00
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/adw-gtk3-dark | sudo tee /etc/dconf/db/local.d/adw-gtk3-dark > /dev/null
|
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/automount-disable | sudo tee /etc/dconf/db/local.d/automount-disable > /dev/null
|
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/prefer-dark | sudo tee /etc/dconf/db/local.d/prefer-dark > /dev/null
|
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/privacy | sudo tee /etc/dconf/db/local.d/privacy > /dev/null
|
2024-05-17 05:54:50 -04:00
|
|
|
|
|
|
|
sudo dconf update
|
|
|
|
umask 077
|
|
|
|
|
|
|
|
# Avoid phased updates
|
2024-07-03 05:19:13 -04:00
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/apt/apt.conf.d/99sane-upgrades | sudo tee /etc/apt/apt.conf.d/99sane-upgrades > /dev/null
|
2024-05-17 05:54:50 -04:00
|
|
|
sudo chmod 644 /etc/apt/apt.conf.d/99sane-upgrades
|
|
|
|
|
2024-05-17 06:04:28 -04:00
|
|
|
|
|
|
|
sudo apt update -y
|
|
|
|
sudo apt full-upgrade -y
|
|
|
|
sudo apt autoremove -y
|
|
|
|
|
2024-05-17 05:54:50 -04:00
|
|
|
# Debloat
|
2024-05-21 21:54:15 -04:00
|
|
|
|
|
|
|
# Remove unnecessary stuff from the Qubes template
|
2024-05-23 16:59:59 -04:00
|
|
|
sudo apt purge -y gnome-software thunderbird keepassxc
|
2024-05-22 02:08:11 -04:00
|
|
|
|
|
|
|
# Remove Network + hardware tools packages
|
2024-05-22 06:10:01 -04:00
|
|
|
sudo apt purge -y avahi* cups* '*nfs*' rygel '*smtp*' system-config-printer* '*telnet*'
|
2024-05-22 02:08:11 -04:00
|
|
|
|
|
|
|
# Remove support for some languages and spelling
|
|
|
|
sudo apt purge -y '*speech*'
|
|
|
|
|
|
|
|
# Remove codec + image + printers
|
|
|
|
sudo apt purge -y ImageMagick* sane* simple-scan
|
|
|
|
|
|
|
|
# Remove Active Directory + Sysadmin + reporting tools
|
|
|
|
sudo apt purge -y realmd
|
|
|
|
|
2024-05-22 06:10:01 -04:00
|
|
|
# Remove unnecessary network tools
|
|
|
|
sudo apt purge -y ifupdown mobile-broadband-provider-info modemmanager
|
|
|
|
|
2024-05-22 02:08:11 -04:00
|
|
|
# Remove Gnome apps
|
2024-05-22 06:10:01 -04:00
|
|
|
sudo apt purge -y baobab chrome-gnome-shell eog gnome-calculator gnome-calendar gnome-characters gnome-clocks gnome-color-manager \
|
|
|
|
gnome-contacts gnome-disk-utility gnome-font-viewer gnome-logs gnome-maps gnome-music gnome-remote-desktop gnome-shell-extensions \
|
|
|
|
gnome-sound-recorder gnome-tweaks gnome-user-share gnome-weather totem
|
2024-05-21 21:54:15 -04:00
|
|
|
|
|
|
|
# Remove apps
|
2024-05-22 06:10:01 -04:00
|
|
|
sudo apt purge -y cheese evince evolution file-roller* firefox* libreoffice* seahorse shotwell synaptic* rhythmbox yelp
|
|
|
|
|
|
|
|
# Remove other packages
|
|
|
|
sudo apt purge -y cron lvm2 lynx '*vmware*' xserver-xephyr xsettingsd
|
2024-05-21 21:54:15 -04:00
|
|
|
|
2024-05-17 05:54:50 -04:00
|
|
|
sudo apt autoremove -y
|
|
|
|
sudo apt autoclean
|
|
|
|
|
2024-05-22 06:10:01 -04:00
|
|
|
# Add console group
|
|
|
|
sudo groupadd --system console
|
|
|
|
sudo usermod -aG console user
|
|
|
|
|
|
|
|
# Add extrepo
|
|
|
|
sudo apt install -y extrepo
|
|
|
|
|
2024-05-21 21:54:15 -04:00
|
|
|
# Adding KickSecure's repo
|
|
|
|
sudo http_proxy=http://127.0.0.1:8082 https_proxy=http://127.0.0.1:8082 extrepo enable kicksecure
|
|
|
|
|
2024-05-17 05:54:50 -04:00
|
|
|
# Distribution morphing
|
2024-05-17 06:04:28 -04:00
|
|
|
sudo apt update
|
2024-05-22 06:13:20 -04:00
|
|
|
sudo apt full-upgrade -y
|
2024-05-17 05:54:50 -04:00
|
|
|
sudo apt install --no-install-recommends kicksecure-qubes-cli -y
|
|
|
|
sudo apt autoremove -y
|
2024-05-17 06:07:22 -04:00
|
|
|
sudo repository-dist --enable --repository stable-proposed-updates
|
|
|
|
sudo extrepo disable kicksecure
|
2024-05-17 05:54:50 -04:00
|
|
|
sudo mv /etc/apt/sources.list ~/
|
|
|
|
sudo touch /etc/apt/sources.list
|
|
|
|
|
2024-05-17 06:07:22 -04:00
|
|
|
#Enabling SUID Disabler and Permission Hardener
|
2024-05-17 05:54:50 -04:00
|
|
|
sudo systemctl enable --now permission-hardening
|
|
|
|
|
|
|
|
# Restrict /proc and access
|
|
|
|
sudo systemctl enable --now proc-hidepid.service
|
|
|
|
|
|
|
|
# Reduce kernel information leaks
|
|
|
|
# Will break a lot of applications. The apps I use on KickSecure work fine with it so I am enabling it.
|
|
|
|
sudo systemctl enable --now hide-hardware-info.service
|
|
|
|
|
|
|
|
# Install packages
|
2024-05-25 01:49:13 -04:00
|
|
|
sudo apt install --no-install-recommends adw-gtk3-theme gnome-console loupe qubes-ctap qubes-gpg-split -y
|
2024-05-17 05:54:50 -04:00
|
|
|
|
|
|
|
# Flatpak update service
|
2024-07-03 05:19:13 -04:00
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/QubesOS-Scripts/main/etc/systemd/user/update-user-flatpaks.service | sudo tee /etc/systemd/user/update-user-flatpaks.service > /dev/null
|
|
|
|
unpriv curl -s --proxy http://127.0.0.1:8082 https://raw.githubusercontent.com/TommyTran732/QubesOS-Scripts/main/etc/systemd/user/update-user-flatpaks.timer | sudo tee /etc/systemd/user/update-user-flatpaks.timer > /dev/null
|