Compare commits

..

20 Commits

Author SHA1 Message Date
d69b39f20c Merge pull request 'Update bootstrap.sh' (#20) from dev into prod
Reviewed-on: #20
2026-07-26 16:51:20 +02:00
44b0b866b8 Update bootstrap.sh 2026-07-26 16:51:03 +02:00
6092772d88 Merge pull request 'Update bootstrap.sh' (#19) from dev into prod
Reviewed-on: #19
2026-07-26 16:28:32 +02:00
35a7d7888f Update bootstrap.sh 2026-07-26 16:27:55 +02:00
629c54b21c Merge pull request 'Update bootstrap.sh' (#18) from dev into prod
Reviewed-on: #18
2026-07-23 17:50:25 +02:00
2d5f13ba98 Update bootstrap.sh 2026-07-23 17:50:15 +02:00
448c5516c9 Merge pull request 'Update bootstrap.sh' (#17) from dev into prod
Reviewed-on: #17
2026-07-23 17:41:25 +02:00
1a35d6d60a Update bootstrap.sh 2026-07-23 17:41:06 +02:00
ed3d309691 Merge pull request 'Update bootstrap.sh' (#16) from dev into prod
Reviewed-on: #16
2026-07-01 22:33:42 +02:00
521f77cf5b Update bootstrap.sh 2026-07-01 22:33:25 +02:00
b5edca7adf Merge pull request 'Update bootstrap.sh' (#15) from dev into prod
Reviewed-on: #15
2026-06-12 18:18:02 +02:00
018ce95617 Update bootstrap.sh 2026-06-12 18:17:54 +02:00
7deb076d3d Merge pull request 'Update bootstrap.sh' (#14) from dev into prod
Reviewed-on: #14
2026-06-12 18:11:50 +02:00
ce9e345d37 Update bootstrap.sh 2026-06-12 18:11:39 +02:00
668ea5c5e2 Merge pull request 'Update bootstrap.sh' (#13) from dev into prod
Reviewed-on: #13
2026-06-12 17:57:10 +02:00
8dd3bbe8a3 Update bootstrap.sh 2026-06-12 17:57:02 +02:00
401df4602a Merge pull request 'Update bootstrap.sh' (#12) from dev into prod
Reviewed-on: #12
2026-06-12 17:54:34 +02:00
89d496bfdd Update bootstrap.sh 2026-06-12 17:54:25 +02:00
7fcaf9a84d Merge pull request 'Update bootstrap.sh' (#11) from dev into prod
Reviewed-on: #11
2026-06-12 17:53:10 +02:00
003dc11383 Update bootstrap.sh 2026-06-12 17:53:01 +02:00

View File

@@ -11,13 +11,15 @@ CRONTABTMP="/tmp/crontab.root.tmp"
HOSTNAME=$(hostname)
KEYFILE="/root/.ssh/$HOSTNAME"
TEMP_SCRIPT="/root/firstlogin.sh"
TEMP_SCRIPT_WRAPPER="root/firstloginwrapper.sh"
TEMP_SCRIPT_CLEANER="root/firstlogincleaner.sh"
TEMP_SCRIPT_WRAPPER="/root/firstloginwrapper.sh"
TEMP_SCRIPT_CLEANER="/root/firstlogincleaner.sh"
#################. ALIASES
echo "alias ll='ls -l --color=auto'" >> ~/.bashrc
echo "alias l='ls -lAh --color=auto'" >> ~/.bashrc
echo "" >> ~/.bashrc
echo 'PS1="\u\[\e[0m\]@\[\e[31m\]\h\[\e[0m\]:\[\e[34m\]\w\[\e[0m\]# "' >> ~/.bashrc
source ~/.bashrc
@@ -89,7 +91,7 @@ sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd
systemctl restart sshd
# Nettoyage différé
nohup /root/first-login-cleaner.sh >/dev/null 2>&1 &
nohup /root/firstlogincleaner.sh >/dev/null 2>&1 &
exit 0
EOF
chmod +x $TEMP_SCRIPT
@@ -99,8 +101,8 @@ chmod +x $TEMP_SCRIPT
cat << 'EOF' > $TEMP_SCRIPT_WRAPPER
#!/bin/bash
if [ -f /root/first-login.sh ]; then
/root/first-login.sh
if [ -f /root/firstlogin.sh ]; then
/root/firstlogin.sh
fi
exit 0
@@ -112,21 +114,22 @@ cat << 'EOF' > $TEMP_SCRIPT_CLEANER
#!/bin/bash
# Attendre la fin du login
sleep 10
sleep 2
# Supprimer la ligne PAM
sed -i '/first-login-wrapper.sh/d' /etc/pam.d/sshd
sed -i '/firstloginwrapper.sh/d' /etc/pam.d/sshd
# Supprimer les scripts
rm -f /root/first-login.sh
rm -f /root/first-login-wrapper.sh
rm -f /root/first-login-cleaner.sh
rm -f /root/firstlogin.sh
rm -f /root/firstloginwrapper.sh
rm -f /root/firstlogincleaner.sh
rm -f /root/bootstrap.sh
exit 0
EOF
chmod +x $TEMP_SCRIPT_CLEANER
echo "auth optional pam_exec.so stdout /root/first-login-wrapper.sh" >> /etc/pam.d/sshd
echo "auth optional pam_exec.so stdout /root/firstloginwrapper.sh" >> /etc/pam.d/sshd
#################. Hardening binaries
@@ -135,6 +138,7 @@ mv $REBOOTBIN $REBOOTBINOLD
cat << 'EOF' > $REBOOTBIN
#!/bin/bash
touch /var/log/restart-flag
echo "[REBOOT] Rebooting server..."
sleep 1
/usr/sbin/reboot.old
EOF
@@ -144,6 +148,7 @@ chmod +x $REBOOTBIN
cat << 'EOF' > $SHUTBIN
#!/bin/bash
touch /var/log/restart-flag
echo "[SHUTDOWN] Stopping server..."
sleep 1
shutdown -h now
EOF
@@ -206,3 +211,8 @@ ssh-keygen -t ed25519 -C "$HOSTNAME" -f "$KEYFILE" -N ""
# Ajouter la clé publique dans authorized_keys
cat "${KEYFILE}.pub" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
rm -fr /etc/systemd/system/bootstrap.service
rm -fr /etc/systemd/system/multi-user.target.wants/bootstrap.service
rm -fr /root/run-bootstrap.sh
systemctl daemon-reload