Advertisement
jay_lltv

systemd unit for resetting ssh host keys

Oct 18th, 2021
853
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None
  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
RAW Paste Data Copied
Advertisement