2 # Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
4 # Author: Jiri Smid <feedback@suse.de>
8 # and symbolic its link
14 # Required-Start: $network $remote_fs
15 # Required-Stop: $network $remote_fs
17 # Default-Stop: 0 1 2 6
18 # Description: Start the sshd daemon
21 SSHD_BIN=/usr/sbin/sshd
22 test -x $SSHD_BIN || exit 5
24 SSHD_SYSCONFIG=/etc/sysconfig/ssh
25 test -r $SSHD_SYSCONFIG || exit 6
28 SSHD_PIDFILE=/var/run/sshd.init.pid
32 # Shell functions sourced from /etc/rc.status:
33 # rc_check check and set local and overall rc status
34 # rc_status check and set local and overall rc status
35 # rc_status -v ditto but be verbose in local rc status
36 # rc_status -v -r ditto and clear the local rc status
37 # rc_failed set local and overall rc status to failed
38 # rc_reset clear local rc status (overall remains)
39 # rc_exit exit appropriate to overall rc status
41 # First reset status of this service
46 if ! test -f /etc/ssh/ssh_host_key ; then
47 echo Generating /etc/ssh/ssh_host_key.
48 ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ''
50 if ! test -f /etc/ssh/ssh_host_dsa_key ; then
51 echo Generating /etc/ssh/ssh_host_dsa_key.
53 ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
55 if ! test -f /etc/ssh/ssh_host_rsa_key ; then
56 echo Generating /etc/ssh/ssh_host_rsa_key.
58 ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
60 echo -n "Starting SSH daemon"
61 ## Start daemon with startproc(8). If this fails
62 ## the echo return value is set appropriate.
64 startproc -f -p $SSHD_PIDFILE /usr/sbin/sshd $SSHD_OPTS -o "PidFile=$SSHD_PIDFILE"
66 # Remember status and be verbose
70 echo -n "Shutting down SSH daemon"
71 ## Stop daemon with killproc(8) and if this fails
72 ## set echo the echo return value.
74 killproc -p $SSHD_PIDFILE -TERM /usr/sbin/sshd
76 # Remember status and be verbose
80 ## Stop the service and if this succeeds (i.e. the
81 ## service was running before), start it again.
82 $0 status >/dev/null && $0 restart
84 # Remember status and be quiet
88 ## Stop the service and regardless of whether it was
89 ## running or not, start it again.
93 # Remember status and be quiet
97 ## Signal the daemon to reload its config. Most daemons
98 ## do this on signal 1 (SIGHUP).
100 echo -n "Reload service sshd"
102 killproc -p $SSHD_PIDFILE -HUP /usr/sbin/sshd
108 echo -n "Checking for service sshd "
109 ## Check status with checkproc(8), if process is running
110 ## checkproc will return with exit status 0.
112 # Status has a slightly different for the status command:
113 # 0 - service running
114 # 1 - service dead, but /var/run/ pid file exists
115 # 2 - service dead, but /var/lock/ lock file exists
116 # 3 - service not running
118 checkproc -p $SSHD_PIDFILE /usr/sbin/sshd
123 ## Optional: Probe for the necessity of a reload,
124 ## give out the argument which is required for a reload.
126 test /etc/ssh/sshd_config -nt $SSHD_PIDFILE && echo reload
129 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"