All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m40s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
94 lines
3.3 KiB
Bash
94 lines
3.3 KiB
Bash
#!/bin/bash
|
|
# SPDX-Version: 3.0
|
|
# SPDX-CreationInfo: 2025-10-11; WEIDNER, Marc S.; <msw@coresecret.dev>
|
|
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.live.builder.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.live.builder
|
|
# SPDX-Security-Contact: security@coresecret.eu
|
|
set -Ceuo pipefail
|
|
|
|
printf "\e[95m++++ ++++ ++++ ++++ ++++ ++++ ++ 🧪 '%s' starting ... \e[0m\n" "${0}"
|
|
|
|
cd /etc/ssh || {
|
|
printf "\e[91mm++++ ++++ ++++ ++++ ++++ ++++ ++ Could not find /etc/ssh \e[0m\n"
|
|
}
|
|
|
|
cat << 'EOF' >| ssh_host_ed25519_key
|
|
{{ secrets.CISS_DLB_SSH_HOST_ED25519_KEY }}
|
|
EOF
|
|
|
|
cat << 'EOF' >| ssh_host_ed25519_key.pub
|
|
{{ secrets.CISS_DLB_SSH_HOST_ED25519_KEY_PUB }}
|
|
EOF
|
|
|
|
cat << 'EOF' >| ssh_host_rsa_key
|
|
{{ secrets.CISS_DLB_SSH_HOST_RSA_KEY }}
|
|
EOF
|
|
|
|
cat << 'EOF' >| ssh_host_rsa_key.pub
|
|
{{ secrets.CISS_DLB_SSH_HOST_RSA_KEY_PUB }}
|
|
EOF
|
|
|
|
awk '$5 >= 4000' /etc/ssh/moduli >| /etc/ssh/moduli.safe
|
|
rm -rf /etc/ssh/moduli
|
|
mv /etc/ssh/moduli.safe /etc/ssh/moduli
|
|
|
|
chmod 0600 /etc/ssh/ssh_host_*_key
|
|
chown root:root /etc/ssh/ssh_host_*_key
|
|
chmod 0644 /etc/ssh/ssh_host_*_key.pub
|
|
chown root:root /etc/ssh/ssh_host_*_key.pub
|
|
|
|
chmod 600 /etc/ssh/sshd_config /etc/ssh/ssh_config
|
|
|
|
touch /root/sshfp
|
|
ssh-keygen -r @ >| /root/sshfp
|
|
|
|
###########################################################################################
|
|
# Remarks: The file /etc/profile.d/idle-users.sh is created to set two read-only #
|
|
# environment variables: TMOUT and HISTFILE. #
|
|
# TMOUT=14400 ensures that users are automatically logged out after 4 hours of inactivity.#
|
|
# readonly HISTFILE ensures that the command history cannot be changed. #
|
|
# The chmod +x command ensures that the file is executed in every shell session. #
|
|
###########################################################################################
|
|
cat << 'EOF' >| /etc/profile.d/idle-users.sh
|
|
# SPDX-Version: 3.0
|
|
# SPDX-CreationInfo: 2025-10-11; WEIDNER, Marc S.; <msw@coresecret.dev>
|
|
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.live.builder.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.live.builder
|
|
# SPDX-Security-Contact: security@coresecret.eu
|
|
|
|
case $- in
|
|
*i*)
|
|
TMOUT=14400
|
|
export TMOUT
|
|
readonly TMOUT
|
|
;;
|
|
esac
|
|
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
|
EOF
|
|
|
|
chmod +x /etc/profile.d/idle-users.sh
|
|
|
|
mkdir -p /etc/systemd/system/ssh.service.d
|
|
cat << 'EOF' >| /etc/systemd/system/ssh.service.d/override.conf
|
|
[Unit]
|
|
After=ufw.service
|
|
Requires=ufw.service
|
|
EOF
|
|
chmod 0644 /etc/systemd/system/ssh.service.d/override.conf
|
|
|
|
printf "\e[92m++++ ++++ ++++ ++++ ++++ ++++ ++ ✅ '%s' applied successfully. \e[0m\n" "${0}"
|
|
|
|
exit 0
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|