Actualiser miscellaneous/secure_ssh.sh
This commit is contained in:
@@ -170,6 +170,8 @@ EOL
|
|||||||
echo "# IP address access restriction" >> "$SSHD_CONFIG"
|
echo "# IP address access restriction" >> "$SSHD_CONFIG"
|
||||||
echo "Match Address $(echo "$ALLOWED_IPS" | tr ' ' ',')" >> "$SSHD_CONFIG"
|
echo "Match Address $(echo "$ALLOWED_IPS" | tr ' ' ',')" >> "$SSHD_CONFIG"
|
||||||
echo " AllowUsers *" >> "$SSHD_CONFIG"
|
echo " AllowUsers *" >> "$SSHD_CONFIG"
|
||||||
|
echo "Match Address *,!$(echo "$ALLOWED_IPS" | tr ' ' ',')" >> "$SSHD_CONFIG"
|
||||||
|
echo " DenyUsers *" >> "$SSHD_CONFIG"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,9 +195,9 @@ main() {
|
|||||||
# Warning message before proceeding with the script.
|
# 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 "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."
|
echo "The root user will not be able to connect."
|
||||||
|
|
||||||
read -p "Do you want to continue? (yes/no): " CONTINUE
|
read -p "Do you want to continue? (yes/no): " CONTINUE
|
||||||
|
|
||||||
if [[ ! "$CONTINUE" =~ ^([yY]es|[oO]ui)$ ]]; then
|
if [[ ! "$CONTINUE" =~ ^([yY]es|[oO]ui)$ ]]; then
|
||||||
echo "Exiting script."
|
echo "Exiting script."
|
||||||
exit 0
|
exit 0
|
||||||
@@ -240,4 +242,4 @@ main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Execute the main process
|
# Execute the main process
|
||||||
main
|
main
|
||||||
|
|||||||
Reference in New Issue
Block a user