3 # Init file for OpenSSH server daemon
5 # chkconfig: 2345 55 25
6 # description: OpenSSH server daemon
9 # config: /etc/ssh/ssh_host_key
10 # config: /etc/ssh/ssh_host_key.pub
11 # config: /etc/ssh/ssh_random_seed
12 # config: /etc/ssh/sshd_config
13 # pidfile: /var/run/sshd.pid
15 # source function library
16 . /etc/rc.d/init.d/functions
18 # pull in sysconfig settings
19 [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
24 # Some functions to make the below more readable
26 PID_FILE=/var/run/sshd.pid
28 do_restart_sanity_check()
32 if [ $RETVAL -ne 0 ]; then
33 failure $"Configuration file or keys are invalid"
40 # Create keys if necessary
41 /usr/bin/ssh-keygen -A
42 if [ -x /sbin/restorecon ]; then
43 /sbin/restorecon /etc/ssh/ssh_host_key.pub
44 /sbin/restorecon /etc/ssh/ssh_host_rsa_key.pub
45 /sbin/restorecon /etc/ssh/ssh_host_dsa_key.pub
46 /sbin/restorecon /etc/ssh/ssh_host_ecdsa_key.pub
49 echo -n $"Starting $prog:"
50 $SSHD $OPTIONS && success || failure
52 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd
58 echo -n $"Stopping $prog:"
61 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sshd
67 echo -n $"Reloading $prog:"
88 if [ -f /var/lock/subsys/sshd ] ; then
89 do_restart_sanity_check
90 if [ $RETVAL -eq 0 ] ; then
103 echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"