Skip to content

Commit

Permalink
Merge pull request #493 from konstruktoid/sshkeys
Browse files Browse the repository at this point in the history
fix sshd host key permissions
  • Loading branch information
konstruktoid authored Jan 17, 2024
2 parents 2ce8406 + fcb4cf6 commit 3e782ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 2 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ provisioner:
sshd_allow_groups:
- vagrant
- sudo
sshd_host_keys_group: ssh_keys
sshd_update_moduli: true
suid_sgid_permissions: false
almalinux9:
Expand All @@ -31,6 +32,7 @@ provisioner:
sshd_allow_groups:
- vagrant
- sudo
sshd_host_keys_group: ssh_keys
sshd_update_moduli: true
bookworm:
ansible_become_pass: vagrant
Expand Down
14 changes: 3 additions & 11 deletions tasks/sshconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,6 @@
- /etc/ssh/ssh_host_ed25519_key
when: ssh_installed_version is version('6.5', '>=')

- name: Change host private key ownership, group and permissions
ansible.builtin.file:
path: "{{ item }}"
owner: "{{ sshd_host_keys_owner }}"
group: "{{ sshd_host_keys_group }}"
mode: "{{ sshd_host_keys_mode }}"
loop: "{{ sshd_host_keys_files }}"

- name: Disable PAM dynamic MOTD
become: true
community.general.pamd:
Expand Down Expand Up @@ -356,9 +348,9 @@
- name: Set sshd host key permissions
become: true
ansible.builtin.file:
owner: root
group: root
mode: "0600"
owner: "{{ sshd_host_keys_owner }}"
group: "{{ sshd_host_keys_group }}"
mode: "{{ sshd_host_keys_mode }}"
path: "{{ item.path }}"
loop: "{{ ssh_host_keys.files }}"
loop_control:
Expand Down

0 comments on commit 3e782ed

Please sign in to comment.