- name: Disallow root SSH access lineinfile: dest: /etc/ssh/sshd_config regexp: "^PermitRootLogin no" line: "PermitRootLogin no" state: present notify: - restart sshd
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5ff043fb-1b91-12f2-a90d-9f4e4120f65d%40linuxia.de.
Jonathan Cha'gara Lozada De La Matta
He / Him / His
Senior Automation Practice Consultant & Automation CoP Manager
Join the Automation CoP! https://red.ht/autocop
I think its common practice to "harden" SSH by running the following in one of your playbooks:
- name: Disallow root SSH accesslineinfile:dest: /etc/ssh/sshd_configregexp: "^PermitRootLogin no"line: "PermitRootLogin no"state: presentnotify:- restart sshd
regexp: "^(#|#\s|\s|)PermitRootLogin(\s*)(no|yes)"
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4a803c9e-7cc5-4b0e-873f-c50814b68c09%40googlegroups.com.
@Jon glad you found a solution that works for you. Strangely I don't have issues with just one backslash. Might be due to the old python version that is used on macOS.
@Stefan thanks for the correction!
@SCRigler basically you are right. But if someone sees the line that is commented out she/he might think the setting fell back to the default setting and close the config file again without noticing that way down in the config file there is actually a working setting that does overwrite the default. Might make troubleshooting a bit more frustrating that way.
"S C Rigler" ---05.09.2019 15:39:57---All of these regex's seem a little too specific. Why not just: regexp: '^PermitRootLogin\b'
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/5MsNYWEQrYA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFbiokcM%2BatiH0bR8gvH5NbLTz%2Bpr%3DSWt0YBK0fVpxXn%3DUU%3DDQ%40mail.gmail.com.