check-ssh.sh 1.5KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. case $1 in
  3. Protocol)
  4. if [ "$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep -w "^Protocol" | awk '{print $2}')" -ne 2 ];then
  5. exit 1
  6. fi
  7. ;;
  8. rhosts)
  9. if [ "$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep -i IgnoreRhosts | awk '{print $2}')" != "yes" ];then
  10. exit 1
  11. fi
  12. ;;
  13. hostauth)
  14. if [ "$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep -i HostbasedAuthentication | awk '{print $2}')" != "no" ];then
  15. exit 1
  16. fi
  17. ;;
  18. permitroot)
  19. if [ "$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep -i PermitRootLogin | awk '{print $2}')" != "no" ];then
  20. exit 1
  21. fi
  22. ;;
  23. emptypassword)
  24. if [ "$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep -i PermitEmptyPasswords | awk '{print $2}')" != "no" ];then
  25. exit 1
  26. fi
  27. ;;
  28. emptypasswordenvironment)
  29. if [ "$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep -i PermitEmptyPasswords | awk '{print $2}')" != "no" ];then
  30. exit 1
  31. fi
  32. ;;
  33. esac