Advertisement
jay_lltv

systemd unit for resetting ssh host keys

Oct 18th, 2021
3,243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. [Unit]
  2. Description=Regenerate SSH host keys
  3. Before=ssh.service
  4. ConditionFileIsExecutable=/usr/bin/ssh-keygen
  5.  
  6. [Service]
  7. Type=oneshot
  8. ExecStartPre=-/bin/dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096
  9. ExecStartPre=-/bin/sh -c "/bin/rm -f -v /etc/ssh/ssh_host_*_key*"
  10. ExecStart=/usr/bin/ssh-keygen -A -v
  11. ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys
  12.  
  13. [Install]
  14. WantedBy=multi-user.target
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement