01-renew-ssh-keys 517 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. # Licence : GPL v3
  3. # Author: Laurent HUBERT
  4. #
  5. # Renews the ssh server keys if they exist
  6. #
  7. cat <<EOF
  8. ##################################
  9. # Renewing SSH server keys #
  10. ##################################
  11. EOF
  12. status=0
  13. ls /etc/ssh/ssh_host_*key* > /dev/null 2>&1 && dpkg-reconfigure openssh-server || status=1
  14. if [ 0 -ne "$status" ]
  15. then
  16. # Exit with non zero status
  17. echo "Error renewing SSH keys"
  18. exit 1
  19. else
  20. cat <<-EOF
  21. # Renewing SSH server keys: OK #
  22. ##################################
  23. EOF
  24. fi