pilc_regenerate_ssh_host_keys.sh 701 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. export PATH=/bin:/usr/bin:/sbin:/usr/sbin
  3. export LC_ALL=C LANGUAGE=C LANG=C
  4. if [ "$1" = "SECOND_STAGE" ]; then
  5. echo "Seeding /dev/urandom..."
  6. dd if=/dev/hwrng of=/dev/urandom count=16 bs=1024
  7. echo "Regenerating SSH keys..."
  8. rm -f /etc/ssh/ssh_host_*_key*
  9. if ssh-keygen -A -v; then
  10. echo "Starting SSH daemon..."
  11. rm -f /etc/ssh/sshd_not_to_be_run
  12. systemctl enable ssh
  13. systemctl start ssh
  14. echo "Disabling regeneration trigger..."
  15. systemctl disable pilc_regenerate_ssh_host_keys
  16. echo "Done."
  17. else
  18. echo "FAILED to regenerate SSH keys."
  19. fi
  20. else
  21. nohup sh /etc/ssh/pilc_regenerate_ssh_host_keys.sh SECOND_STAGE >/var/log/pilc_regenerate_ssh_host_keys.log 2>&1 &
  22. fi
  23. exit 0