V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 37s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 37s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
38
func/4145_setup_machineid.sh
Normal file
38
func/4145_setup_machineid.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
# SPDX-Version: 3.0
|
||||
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
|
||||
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
|
||||
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||
# SPDX-FileType: SOURCE
|
||||
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
|
||||
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
|
||||
# SPDX-PackageName: CISS.debian.installer
|
||||
# SPDX-Security-Contact: security@coresecret.eu
|
||||
|
||||
guard_sourcing
|
||||
|
||||
#######################################
|
||||
# Updating 'machine-id' to 'whonix id'.
|
||||
# Globals:
|
||||
# TARGET
|
||||
# VAR_SETUP_PATH
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# 0: on success
|
||||
#######################################
|
||||
setup_machineid() {
|
||||
if [[ -f "${TARGET}/var/lib/dbus/machine-id" ]]; then
|
||||
rm -f "${TARGET}/var/lib/dbus/machine-id"
|
||||
fi
|
||||
install -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/etc/machine-id" "${TARGET}/var/lib/dbus/machine-id"
|
||||
|
||||
if [[ -f "${TARGET}/etc/machine-id" ]]; then
|
||||
rm -f "${TARGET}/etc/machine-id"
|
||||
fi
|
||||
install -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/etc/machine-id" "${TARGET}/etc/machine-id"
|
||||
|
||||
return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
@@ -40,6 +40,10 @@ setup_ssh() {
|
||||
declare -i i
|
||||
declare var_auth="" var_name=""
|
||||
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/etc/banner" "${TARGET}/etc/"
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/etc/motd" "${TARGET}/etc/"
|
||||
do_log "info" "true" "Installed SSH banner and motd to '${TARGET}/etc/'."
|
||||
|
||||
### Only process those for which both *_name and *_authentication_access_ssh are set.
|
||||
for ((i = 0; i <= VAR_USER_MAX; i++)); do
|
||||
var_auth="user_user${i}_authentication_access_ssh"
|
||||
@@ -64,8 +68,7 @@ setup_ssh() {
|
||||
|
||||
rm -f "${TARGET}/etc/ssh/sshd_config"
|
||||
|
||||
cp "${VAR_SETUP_PATH}/includes/etc/ssh/sshd_config" "${TARGET}/etc/ssh/sshd_config"
|
||||
chmod 0600 "${TARGET}/etc/ssh/sshd_config"
|
||||
install -D -m 0600 -o root -g root "${VAR_SETUP_PATH}/includes/etc/ssh/sshd_config" "${TARGET}/etc/ssh/sshd_config"
|
||||
chmod 0600 "${TARGET}/etc/ssh/ssh_config"
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
@@ -99,7 +102,7 @@ setup_ssh() {
|
||||
# The chmod +x command ensures that the file is executed in every shell session. #
|
||||
###########################################################################################
|
||||
echo "readonly TMOUT=14400" >| "${TARGET}/etc/profile.d/idle-users.sh"
|
||||
# TODO: Check empty value
|
||||
# TODO: Decide: set HISTFILE=/dev/null or leave unset (readonly var requires value!)
|
||||
#echo "readonly HISTFILE" >> "${TARGET}/etc/profile.d/idle-users.sh"
|
||||
chmod +x "${TARGET}/etc/profile.d/idle-users.sh"
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ guard_sourcing
|
||||
# Updating user accounts.
|
||||
# Globals:
|
||||
# TARGET
|
||||
# VAR_SETUP_PATH
|
||||
# VAR_USER_MAX
|
||||
# user_root_authentication_access_ssh
|
||||
# user_root_password
|
||||
@@ -37,10 +38,18 @@ setup_accounts() {
|
||||
declare var_username="" var_fullname="" var_uid="" var_gid="" var_shell="" var_password="" var_sshpubkey="" var_sudo="" \
|
||||
var_restricted="" var_chpasswd="" var_sshdir=""
|
||||
|
||||
### Hardening '/etc/login.defs'
|
||||
rm -f "${TARGET}/etc/login.defs"
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/etc/login.defs" "${TARGET}/etc/"
|
||||
|
||||
### Hardening '/etc/security/pwquality.conf'
|
||||
rm -f "${TARGET}/etc/security/pwquality.conf"
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/etc/security/pwquality.cnf" "${TARGET}/etc/security/pwquality.conf"
|
||||
|
||||
### Preparing the root account
|
||||
chown root:root "${TARGET}/etc/passwd" "${TARGET}/etc/shadow" "${TARGET}/etc/group" "${TARGET}/etc/gshadow"
|
||||
chmod 644 "${TARGET}/etc/passwd" "${TARGET}/etc/group"
|
||||
chmod 600 "${TARGET}/etc/shadow" "${TARGET}/etc/gshadow"
|
||||
chmod 0644 "${TARGET}/etc/passwd" "${TARGET}/etc/group"
|
||||
chmod 0600 "${TARGET}/etc/shadow" "${TARGET}/etc/gshadow"
|
||||
|
||||
if [[ -x "${TARGET}${user_root_shell}" ]]; then
|
||||
do_in_target "${TARGET}" chsh -s "${user_root_shell}" root
|
||||
|
||||
Reference in New Issue
Block a user