evolix-users: disable root ssh login by default

This commit is contained in:
Jérémy Lecour 2017-10-10 22:01:44 +02:00
parent 8435ac192d
commit ae4b9675c2
3 changed files with 20 additions and 0 deletions

View file

@ -1,3 +1,4 @@
---
evolinux_users: {}
evolinux_sudo_group: "evolinux-sudo"
evolinux_root_disable_ssh: True

View file

@ -15,3 +15,6 @@
user: "{{ item.value }}"
with_dict: "{{ evolinux_users }}"
when: evolinux_users != {}
- include: root_disable_ssh.yml
when: evolinux_root_disable_ssh

View file

@ -0,0 +1,16 @@
---
- name: disable root login
replace:
dest: /etc/ssh/sshd_config
regexp: '^PermitRootLogin (yes|without-password)'
replace: "PermitRootLogin no"
notify: reload sshd
- name: remove root from AllowUsers directive
replace:
dest: /etc/ssh/sshd_config
regexp: '^(AllowUsers ((?!root(?:@\S+)?).)*)(\sroot(?:@\S+)?|root(?:@\S+)?\s)(.*)$'
replace: '\1\4'
validate: '/usr/sbin/sshd -T -f %s'
notify: reload sshd