3 # Generic network daemon RC script. If installed as /etc/rc.d/init.d/foobar,
4 # it source /etc/sysconfig/daemons/foobar and looks at the
5 # variable definitions (Bourne shell syntax). Variables marked with an
6 # asterisk are required.
9 # DESCRIPTIVE="@OPENSSH_VERSION@"
10 # * DAEMON=/usr/sbin/sshd
11 # DAEMON_ARGS="-p some_other_port"
15 # Source networking configuration.
16 . /etc/sysconfig/network
18 # Check that networking is up.
19 [ ${NETWORKING} = "no" ] && exit 0
21 # Source function library, check sysconfig/daemon file and source it.
22 . /etc/rc.d/init.d/functions
24 [ -x $DAEMON ] || exit 0
26 # Some functions to make the below more readable
27 KEYGEN=/usr/bin/ssh-keygen
28 RSA1_KEY=/etc/ssh/ssh_host_key
29 RSA_KEY=/etc/ssh/ssh_host_rsa_key
30 DSA_KEY=/etc/ssh/ssh_host_dsa_key
31 PID_FILE=/var/run/sshd.pid
33 if ! test -f $RSA1_KEY ; then
34 echo -n "Generating SSH1 RSA host key: "
35 if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then
36 echo "RSA1 key generation success"
38 echo "RSA1 key generation failure"
44 if ! test -f $RSA_KEY ; then
45 echo -n "Generating SSH2 RSA host key: "
46 if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then
47 echo "RSA key generation success"
49 echo "RSA key generation failure"
55 if ! test -f $DSA_KEY ; then
56 echo -n "Generating SSH2 DSA host key: "
57 if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then
58 echo "DSA key generation success"
60 echo "DSA key generation failure"
66 # See how we were called.
69 # Create keys if necessary
75 [ ! -e $LOCK ] || exit 1
76 echo -n "Starting $SUBSYS services: "
77 start-stop-daemon -S -n $IDENT -x $DAEMON -- $DAEMON_ARGS
84 [ -e $LOCK ] || exit 0
85 echo -n "Stopping $SUBSYS services: "
86 start-stop-daemon -K -n $IDENT -x $DAEMON
95 echo "Usage: $SUBSYS {start|stop|restart}"