This bash script regenerates the SSH host keys on a newly, template created, VM
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

37 řádky
525B

  1. #!/bin/bash
  2. #
  3. # This script regenerates the SSH host keys on a newly,
  4. # template created, VM
  5. #
  6. # Add the full path of the script in /etc/rc.local, just
  7. # above 'exit 0'
  8. if which systemctl
  9. then
  10. systemctl stop ssh
  11. else
  12. service ssh stop
  13. fi
  14. if ls /etc/ssh/ssh_host_* &> /dev/null
  15. then
  16. rm -f /etc/ssh/ssh_host_*
  17. fi
  18. ls /etc/ssh/ssh_host_* &> /dev/null
  19. if [ "$?" -ne 0 ]
  20. then
  21. ssh-keygen -A
  22. fi
  23. if which systemctl
  24. then
  25. systemctl start ssh
  26. else
  27. service ssh start
  28. fi
  29. sed -i "/$0/d" /etc/rc.local
  30. rm -f $0