Execution
Date
16 Sep 2025 10:20:12 +0100
Duration
00:00:02.77
Controller
ssh-gw-4.layershift.com
User
root
Versions
Ansible
2.16.11
ara
1.7.3 / 1.7.3
Python
3.10.10
Summary
1
Hosts
3
Tasks
3
Results
1
Plays
1
Files
0
Records
Task result details
-
StatusOK
-
Duration00:00:00.52
-
PlayPlaybook to deny ssh for plesk servers that do not have shell users
-
TaskOn plesk server run the script
-
Date16 Sep 2025 10:20:14 +0100
-
Module / Actionansible.builtin.shell (/home/ssh-gateway/ansible/kuly/RM10136_firewall_ssh_deny.yaml:9)
| Field | Value |
|---|---|
| changed |
False |
| cmd |
set -o pipefail
set -e
homedirs=$(awk '/HTTPD_VHOSTS_D/ {print $2}' /etc/psa/psa.conf)
bashes=$(grep "$homedirs" /etc/passwd | grep -v "/bin/false" | wc -l)
if [ "$bashes" -eq 0 ]; then
rule_id=$(/usr/sbin/plesk ext firewall --list-json | jq -r '.[] | select(.class=="ssh") | .id')
if [ -n "$rule_id" ]; then
echo "Blocking SSH via Plesk firewall (rule ID: $rule_id)..."
/usr/sbin/plesk ext firewall --set-rule -id "$rule_id" -action deny && /usr/sbin/plesk ext firewall --apply -auto-confirm-this-may-lock-me-out-of-the-server
else
echo "SSH rule not found in firewall!"
fi
else
echo "We have users with shells, skipping"
fi
|
| delta |
0:00:00.010737 |
| end |
2025-09-16 10:20:14.802423 |
| failed_when_result |
False |
| invocation |
{ "module_args": { "_raw_params": "set -o pipefail\nset -e\nhomedirs=$(awk '/HTTPD_VHOSTS_D/ {print $2}' /etc/psa/psa.conf)\nbashes=$(grep \"$homedirs\" /etc/passwd | grep -v \"/bin/false\" | wc -l)\nif [ \"$bashes\" -eq 0 ]; then\n rule_id=$(/usr/sbin/plesk ext firewall --list-json | jq -r '.[] | select(.class==\"ssh\") | .id')\n if [ -n \"$rule_id\" ]; then\n echo \"Blocking SSH via Plesk firewall (rule ID: $rule_id)...\"\n /usr/sbin/plesk ext firewall --set-rule -id \"$rule_id\" -action deny && /usr/sbin/plesk ext firewall --apply -auto-confirm-this-may-lock-me-out-of-the-server\n else\n echo \"SSH rule not found in firewall!\"\n fi\nelse\n echo \"We have users with shells, skipping\"\nfi\n", "_uses_shell": true, "argv": null, "chdir": null, "creates": null, "executable": "/bin/bash", "expand_argument_vars": true, "removes": null, "stdin": null, "stdin_add_newline": true, "strip_empty_ends": true } } |
| msg |
non-zero return code |
| rc |
1 |
| start |
2025-09-16 10:20:14.791686 |
| stderr |
|
| stderr_lines |
[]
|
| stdout |
|
| stdout_lines |
[]
|