01-renew-ssh-keys 625 B

12345678910111213141516171819202122232425262728
  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. renew_ssh_keys(){
  14. rm /etc/ssh/ssh_host_*key*
  15. dpkg-reconfigure openssh-server
  16. status=$?
  17. }
  18. ls /etc/ssh/ssh_host_*key* > /dev/null 2>&1 && renew_ssh_keys || status=1
  19. if [ 0 -ne "$status" ]
  20. then
  21. # Exit with non zero status
  22. echo "### Error renewing SSH keys ###"
  23. exit 1
  24. else
  25. echo "> Renewing SSH server keys : OK <"
  26. exit 0
  27. fi