Skip to content

Commit

Permalink
fix: enhance check to regenerate SSH keys (#795)
Browse files Browse the repository at this point in the history
Enhances the Ansible task to use `copy` versus `lineinfile` to create `/etc/rc.local` with a check for all SSH host keys.
  • Loading branch information
tenthirtyam committed Dec 14, 2023
1 parent 1ee7805 commit 11bfa2b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ansible/roles/configure/tasks/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@

# Tasks for setting SSH keys to regenerate.
- name: "Setting SSH keys to regenerate."
lineinfile:
copy:
dest: /etc/rc.local
create: true
line: "#!/bin/bash\ntest -f /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server\nexit 0\n"
mode: '0755'
content: |
#!/bin/bash
if test -z "$(find /etc/ssh/ -iname 'ssh_host_*_key*')"; then
dpkg-reconfigure openssh-server
fi
exit 0
mode: 0755

0 comments on commit 11bfa2b

Please sign in to comment.