ssh - add ansible login restrictions

This commit is contained in:
Ludovic Cartier
2026-06-18 17:17:37 +02:00
parent 4a4a4fce83
commit e5cf177ee8
2 changed files with 15 additions and 0 deletions
+9
View File
@@ -1,3 +1,12 @@
- name: SSH | configure ansible login restrictions
template:
src: sshd_ansible_conf.j2
dest: /etc/ssh/sshd_config.d/ansible.conf
mode: '0644'
validate: /usr/sbin/sshd -t -f %s
when: ssh_ansible_authorized_ips is defined
register: sshd_conf_changes
- name: SSH | configure root login restrictions - name: SSH | configure root login restrictions
template: template:
src: sshd_root_conf.j2 src: sshd_root_conf.j2
+6
View File
@@ -0,0 +1,6 @@
{% if ssh_ansible_authorized_ips is defined %}
{% for ip in ssh_ansible_authorized_ips %}
Match Address {{ ip }}
AllowUsers ansible
{% endfor %}
{% endif %}