Skip to content

Commit 3474d9a

Browse files
committed
feat(sshd): dedicated sshd.d config file
1 parent 3b619ef commit 3474d9a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

tasks/ssh_cluster_config.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,35 @@
3838
Port {{ pve_ssh_port }}
3939
{% endfor %}
4040
41+
- name: Ensure SSH config directory exists
42+
ansible.builtin.file:
43+
path: /etc/ssh/sshd_config.d
44+
state: directory
45+
mode: "0755"
46+
4147
- name: Allow root logins from PVE cluster hosts
4248
ansible.builtin.blockinfile:
43-
dest: /etc/ssh/sshd_config
49+
dest: /etc/ssh/sshd_config.d/00-pve.conf
50+
create: yes
51+
mode: "0640"
4452
marker: "# {mark}: Allow root logins from PVE hosts (managed by ansible)."
4553
content: |
4654
{% for host in groups[pve_group] %}
4755
Match Address {{ hostvars[host].pve_cluster_ssh_addrs | join(",") }}
48-
PermitRootLogin prohibit-password
56+
PermitRootLogin prohibit-password
4957
{% endfor %}
5058
validate: "/usr/sbin/sshd -t -f %s"
5159
notify:
5260
- reload ssh server configuration
5361

62+
- name: Remove SSH configuration from main sshd_config if present in favor of config in sshd_config.d
63+
ansible.builtin.blockinfile:
64+
path: /etc/ssh/sshd_config
65+
marker: "# {mark}: Allow root logins from PVE hosts (managed by ansible)."
66+
state: absent
67+
notify:
68+
- reload ssh server configuration
69+
5470
- name: Enable and start SSH server
5571
ansible.builtin.systemd:
5672
name: ssh.service

0 commit comments

Comments
 (0)