S50sshd 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. #
  3. # sshd Starts sshd.
  4. #
  5. # Make sure the ssh-keygen progam exists
  6. [ -f /usr/bin/ssh-keygen ] || exit 0
  7. # Check for the SSH1 RSA key
  8. if [ ! -f /etc/ssh_host_key ] ; then
  9. echo Generating RSA Key...
  10. /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh_host_key -C '' -N ''
  11. fi
  12. # Check for the SSH2 RSA key
  13. if [ ! -f /etc/ssh_host_rsa_key ] ; then
  14. echo Generating RSA Key...
  15. /usr/bin/ssh-keygen -t rsa -f /etc/ssh_host_rsa_key -C '' -N ''
  16. fi
  17. # Check for the SSH2 DSA key
  18. if [ ! -f /etc/ssh_host_dsa_key ] ; then
  19. echo Generating DSA Key...
  20. echo THIS CAN TAKE A MINUTE OR TWO DEPENDING ON YOUR PROCESSOR!
  21. echo
  22. /usr/bin/ssh-keygen -t dsa -f /etc/ssh_host_dsa_key -C '' -N ''
  23. fi
  24. # Check for the SSH2 ECDSA key
  25. if [ ! -f /etc/ssh_host_ecdsa_key ]; then
  26. echo Generating ECDSA Key...
  27. echo THIS CAN TAKE A MINUTE OR TWO DEPENDING ON YOUR PROCESSOR!
  28. echo
  29. /usr/bin/ssh-keygen -t ecdsa -f /etc/ssh_host_ecdsa_key -C '' -N ''
  30. fi
  31. umask 077
  32. start() {
  33. echo -n "Starting sshd: "
  34. /usr/sbin/sshd
  35. touch /var/lock/sshd
  36. echo "OK"
  37. }
  38. stop() {
  39. echo -n "Stopping sshd: "
  40. killall sshd
  41. rm -f /var/lock/sshd
  42. echo "OK"
  43. }
  44. restart() {
  45. stop
  46. start
  47. }
  48. case "$1" in
  49. start)
  50. start
  51. ;;
  52. stop)
  53. stop
  54. ;;
  55. restart|reload)
  56. restart
  57. ;;
  58. *)
  59. echo $"Usage: $0 {start|stop|restart}"
  60. exit 1
  61. esac
  62. exit $?