Actualiser miscellaneous/secure_ssh.sh

This commit is contained in:
2025-04-08 05:54:57 +02:00
parent a37a5adae3
commit 99c38cd4c7

View File

@@ -170,6 +170,8 @@ EOL
echo "# IP address access restriction" >> "$SSHD_CONFIG"
echo "Match Address $(echo "$ALLOWED_IPS" | tr ' ' ',')" >> "$SSHD_CONFIG"
echo " AllowUsers *" >> "$SSHD_CONFIG"
echo "Match Address *,!$(echo "$ALLOWED_IPS" | tr ' ' ',')" >> "$SSHD_CONFIG"
echo " DenyUsers *" >> "$SSHD_CONFIG"
fi
}
@@ -193,9 +195,9 @@ main() {
# Warning message before proceeding with the script.
echo "Warning: Before running this script, make sure you have created a user and an SSH key in the authorized_keys file."
echo "The root user will not be able to connect."
read -p "Do you want to continue? (yes/no): " CONTINUE
if [[ ! "$CONTINUE" =~ ^([yY]es|[oO]ui)$ ]]; then
echo "Exiting script."
exit 0
@@ -240,4 +242,4 @@ main() {
}
# Execute the main process
main
main