mirror of
https://github.com/vernu/vps-audit.git
synced 2025-01-23 05:24:58 +03:00
Merge pull request #12 from latetedemelon/patch-3
Unprivileged Port Check
This commit is contained in:
commit
7b51c7f5a4
@ -93,7 +93,6 @@ check_security() {
|
||||
echo "" >> "$REPORT_FILE"
|
||||
}
|
||||
|
||||
|
||||
# Check system uptime
|
||||
UPTIME=$(uptime -p)
|
||||
UPTIME_SINCE=$(uptime -s)
|
||||
@ -144,6 +143,8 @@ else
|
||||
fi
|
||||
|
||||
# Check SSH default port
|
||||
UNPRIVILEGED_PORT_START=$(sysctl -n net.ipv4.ip_unprivileged_port_start)
|
||||
SSH_PORT=""
|
||||
if [ -n "$SSH_CONFIG_OVERRIDES" ] && [ -d "$(dirname "$SSH_CONFIG_OVERRIDES")" ]; then
|
||||
SSH_PORT=$(grep "^Port" $SSH_CONFIG_OVERRIDES /etc/ssh/sshd_config 2>/dev/null | head -1 | awk '{print $2}')
|
||||
else
|
||||
@ -154,6 +155,8 @@ if [ -z "$SSH_PORT" ]; then
|
||||
fi
|
||||
if [ "$SSH_PORT" = "22" ]; then
|
||||
check_security "SSH Port" "WARN" "Using default port 22 - consider changing to a non-standard port for security by obscurity"
|
||||
elif [ "$SSH_PORT" -ge "$UNPRIVILEGED_PORT_START" ]; then
|
||||
check_security "SSH Port" "FAIL" "Using unprivileged port $SSH_PORT - use a port below $UNPRIVILEGED_PORT_START for better security"
|
||||
else
|
||||
check_security "SSH Port" "PASS" "Using non-default port $SSH_PORT which helps prevent automated attacks"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user