V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 50s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 50s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -25,20 +25,41 @@ kernel_modules() {
|
||||
### Entropy collection improvements
|
||||
mkdir -p "${TARGET}/usr/lib/modules-load.d"
|
||||
cat << EOF >| "${TARGET}/usr/lib/modules-load.d/30_security-misc.conf"
|
||||
## The jitterentropy_rng kernel module provides a reliable and hardware-independent source of cryptographic entropy by measuring
|
||||
## minute variations in CPU execution timing (jitter). These microsecond-level differences are unpredictable and rooted in
|
||||
## physical randomness, making them suitable for high-quality entropy generation. Unlike other RNG methods that rely on hardware
|
||||
## features like TPMs or Intel's RDRAND, which may not be available or trusted, jitterentropy_rng works across all platforms,
|
||||
## including virtual machines and air-gapped systems. It is compliant with NIST SP 800-90B and BSI TR-02102-4, ensuring secure
|
||||
## entropy even during early boot stages, such as in initramfs or before full userland is available. It is the most secure,
|
||||
## standards-compliant, and universally applicable entropy source for hardened Linux environments.
|
||||
## https://www.whonix.org/wiki/Dev/Entropy
|
||||
## https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=927972
|
||||
## https://forums.whonix.org/t/jitterentropy-rngd/7204
|
||||
# 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
|
||||
|
||||
# Static file system information: /usr/lib/modules-load.d/30_security-misc.conf
|
||||
# Generated by CISS.debian.installer ${VAR_VERSION}
|
||||
# Architecture: ${VAR_ARCHITECTURE}
|
||||
# Distribution: ${VAR_CODENAME}
|
||||
|
||||
# The jitterentropy_rng kernel module provides a reliable and hardware-independent source of cryptographic entropy by measuring
|
||||
# minute variations in CPU execution timing (jitter). These microsecond-level differences are unpredictable and rooted in
|
||||
# physical randomness, making them suitable for high-quality entropy generation. Unlike other RNG methods that rely on hardware
|
||||
# features like TPMs or Intel's RDRAND, which may not be available or trusted, jitterentropy_rng works across all platforms,
|
||||
# including virtual machines and air-gapped systems. It is compliant with NIST SP 800-90B and BSI TR-02102-4, ensuring secure
|
||||
# entropy even during early boot stages, such as in initramfs or before full userland is available. It is the most secure,
|
||||
# standards-compliant, and universally applicable entropy source for hardened Linux environments.
|
||||
# https://www.whonix.org/wiki/Dev/Entropy
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=927972
|
||||
# https://forums.whonix.org/t/jitterentropy-rngd/7204
|
||||
|
||||
jitterentropy_rng
|
||||
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/usr/lib/modules-load.d/30_security-misc.conf"
|
||||
|
||||
do_log "info" "file_only" "4400() Installed: '/usr/lib/modules-load.d/30_security-misc.conf'."
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
|
||||
@@ -55,7 +76,11 @@ EOF
|
||||
kernel_modprobe() {
|
||||
install -D -m 0755 -o root -g root "${VAR_SETUP_PATH}/includes/target/etc/modprobe.d/0000_ciss_debian_installer.cnf" \
|
||||
"${TARGET}/etc/modprobe.d/0000_ciss_debian_installer.conf"
|
||||
|
||||
insert_comments "${TARGET}/etc/modprobe.d/0000_ciss_debian_installer.conf"
|
||||
|
||||
do_log "info" "file_only" "4400() Installed: '/etc/modprobe.d/0000_ciss_debian_installer.conf'."
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -25,7 +25,11 @@ guard_sourcing
|
||||
kernel_sysctl() {
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/target/etc/sysctl.d/99_local.hardened" \
|
||||
"${TARGET}/etc/sysctl.d/99_local.hardened"
|
||||
|
||||
insert_comments "${TARGET}/etc/sysctl.d/99_local.hardened"
|
||||
|
||||
do_log "info" "file_only" "4410() Installed: '/etc/sysctl.d/99_local.hardened'."
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -34,13 +34,13 @@ installation_ssh() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -a ary_user=()
|
||||
declare -i i=0
|
||||
declare var_auth="" var_name=""
|
||||
declare var_auth="" var_name="" var_ca=""
|
||||
|
||||
do_in_target "${TARGET}" apt-get install -y --no-install-recommends --no-install-suggests ssh
|
||||
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/target/etc/banner" "${TARGET}/etc/"
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}/includes/target/etc/motd" "${TARGET}/etc/"
|
||||
do_log "info" "file_only" "4420() Installed SSH banner and motd to '${TARGET}/etc/'."
|
||||
do_log "info" "file_only" "4420() Installed SSH '/etc/banner' and '/etc/motd'."
|
||||
|
||||
### Only process those for which both *_name and *_authentication_access_ssh are set.
|
||||
for ((i = 0; i <= VAR_USER_MAX; i++)); do
|
||||
@@ -59,39 +59,56 @@ installation_ssh() {
|
||||
#shellcheck disable=SC2312
|
||||
do_in_target "${TARGET}" ssh-keygen -o -N "" -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -C "root@${VAR_FINAL_FQDN}-$(date -I)"
|
||||
|
||||
mkdir -p "${DIR_BAK}/etc/ssh"
|
||||
cp "${TARGET}/etc/ssh/sshd_config" "${DIR_BAK}/etc/ssh/sshd_config.bak"
|
||||
chmod 0644 "${DIR_BAK}/etc/ssh/sshd_config.bak"
|
||||
cp "${TARGET}/etc/ssh/ssh_config" "${DIR_BAK}/etc/ssh/ssh_config.bak"
|
||||
chmod 0644 "${DIR_BAK}/etc/ssh/ssh_config.bak"
|
||||
|
||||
mkdir -p "${TARGET}/root/.ciss/cdi/backup/etc/ssh"
|
||||
cp "${TARGET}/etc/ssh/sshd_config" "${TARGET}/root/.ciss/cdi/backup/etc/ssh/sshd_config.bak"
|
||||
cp "${TARGET}/etc/ssh/ssh_config" "${TARGET}/root/.ciss/cdi/backup/etc/ssh/ssh_config.bak"
|
||||
rm -f "${TARGET}/etc/ssh/sshd_config"
|
||||
|
||||
install -D -m 0600 -o root -g root "${VAR_SETUP_PATH}/includes/target/etc/ssh/sshd_config" "${TARGET}/etc/ssh/sshd_config"
|
||||
chmod 0600 "${TARGET}/etc/ssh/ssh_config"
|
||||
|
||||
insert_comments "${TARGET}/etc/ssh/sshd_config"
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
sed -i -E "s|^\s*ListenAddress\s+.*$|$(printf '%-30s%s' 'ListenAddress' "${VAR_FINAL_IPV4}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
#sed -i -E "s|^\s*ListenAddress\s+.*$|$(printf '%-29s%s' 'ListenAddress' "${VAR_FINAL_IPV4}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
sed -i -E "s|^[[:space:]]*ListenAddress[[:space:]]+.*$|$(printf '%-29s%s' 'ListenAddress' "${VAR_FINAL_IPV4}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
|
||||
if [[ -n "${VAR_FINAL_IPV6}" ]]; then
|
||||
sed -i -E "s|^\s*ListenAddress\s+::.*$|$(printf '%-30s%s' 'ListenAddress' "${VAR_FINAL_IPV6}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
#sed -i -E "s|^\s*ListenAddress\s+::.*$|$(printf '%-29s%s' 'ListenAddress' "${VAR_FINAL_IPV6}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
sed -i -E "s|^[[:space:]]*ListenAddress[[:space:]]+::.*$|$(printf '%-29s%s' 'ListenAddress' "${VAR_FINAL_IPV6}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
else
|
||||
sed -i "/^\s*ListenAddress\s*::/d" "${TARGET}/etc/ssh/sshd_config"
|
||||
#sed -i "/^\s*ListenAddress\s*::/d" "${TARGET}/etc/ssh/sshd_config"
|
||||
sed -i "/^[[:space:]]*ListenAddress[[:space:]]*::/d" "${TARGET}/etc/ssh/sshd_config"
|
||||
fi
|
||||
|
||||
sed -i -E "s|^\s*Port\s+.*$|$(printf '%-30s%s' 'Port' "${ssh_port}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
#sed -i -E "s|^\s*Port\s+.*$|$(printf '%-29s%s' 'Port' "${ssh_port}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
sed -i -E "s|^[[:space:]]*Port[[:space:]]+.*$|$(printf '%-29s%s' 'Port' "${ssh_port}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
|
||||
if (( ${#ary_user[@]} > 0 )); then
|
||||
sed -i -E "s|^\s*AllowUsers\s+.*$|$(printf '%-30s%s' 'AllowUsers' "root ${ary_user[*]}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
sed -i -E "s|^\s*AllowUsers\s+.*$|$(printf '%-29s%s' 'AllowUsers' "root ${ary_user[*]}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
fi
|
||||
|
||||
if [[ -n "${ssh_root_ca}" ]]; then
|
||||
var_ca="${ssh_root_ca##*/}"
|
||||
install -D -m 0644 -o root -g root "${VAR_SETUP_PATH}${ssh_root_ca}" "${TARGET}/etc/ssh/"
|
||||
sed -i -E "s|^\s*TrustedUserCAKeys\s+.*$|$(printf '%-30s%s' 'TrustedUserCAKeys' "/etc/ssh/${ssh_root_ca}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
sed -i -E "s|^\s*TrustedUserCAKeys\s+.*$|$(printf '%-29s%s' 'TrustedUserCAKeys' "/etc/ssh/${var_ca}")|" "${TARGET}/etc/ssh/sshd_config"
|
||||
fi
|
||||
|
||||
do_in_target_script "${TARGET}" "sshd -T >| /root/.ciss/cdi/log/sshd_config.log"
|
||||
do_in_target_script "${TARGET}" "ssh-keygen -r ${VAR_FINAL_FQDN}. >| /root/.ciss/cdi/log/ssh.log"
|
||||
### Preparing the test environment in chroot.
|
||||
do_in_target "${TARGET}" install -d -o root -g root -m 0755 /run/sshd
|
||||
|
||||
### Syntax test (hard).
|
||||
if ! do_in_target_script "${TARGET}" "sshd -t -f /etc/ssh/sshd_config"; then
|
||||
do_log "emergency" "file_only" "4420() [sshd -t -f /etc/ssh/sshd_config] failed."
|
||||
return "${ERR_CONF_VALIDATION}"
|
||||
fi
|
||||
|
||||
### Effective configuration (soft, purely informative).
|
||||
if ! do_in_target_script "${TARGET}" "sshd -T -f /etc/ssh/sshd_config >| /root/.ciss/cdi/log/sshd_config.log"; then
|
||||
do_log "warn" "file_only" "4420() [sshd -T -f /etc/ssh/sshd_config] failed. Likely env. Continuing."
|
||||
fi
|
||||
|
||||
do_in_target_script "${TARGET}" "ssh-keygen -r ${VAR_FINAL_FQDN}. >| /root/.ciss/cdi/log/SSHFP.log"
|
||||
|
||||
###########################################################################################
|
||||
# The file /etc/profile.d/idle-users.sh is created to set two read-only #
|
||||
|
||||
Reference in New Issue
Block a user