Skip to content
Snippets Groups Projects
Commit 960b6b87 authored by Baptiste DE RENZO's avatar Baptiste DE RENZO
Browse files

Verify root ssh authorized key file before permitrootlogin modification, Refs #37430

parent 552f577d
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,18 @@
backup: true
notify: restart unattended-upgrades
- name: enable root login via ssh with key
- name: verify root user ssh authorized key file
ansible.builtin.stat:
path: /root/.ssh/authorized_keys
register: auth
- name: fail if the root ssh authorized key is missing or empty
ansible.builtin.fail:
msg: "Error: root user does not have any ssh key configured !\n\
Cannot configure PermitRootLogin to without-password"
when: not auth.stat.exists or auth.stat.size == 0
- name: enable root login via ssh with key only
ansible.builtin.replace:
dest: /etc/ssh/sshd_config
regexp: ^#?PermitRootLogin.*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment