2 # Filename: /etc/init.d/ssh
3 # Purpose: start and stop the OpenBSD "secure shell(tm)" daemon including keyeneration
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Mon Jul 11 01:26:29 CEST 2005 [mika]
8 ################################################################################
10 test -x /usr/sbin/sshd || exit 0
11 ( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0
13 # forget it if we're trying to start, and /etc/ssh/NOSERVER exists
14 if expr "$1" : '.*start$' >/dev/null && [ -e /etc/ssh/NOSERVER ]; then
15 echo "Not starting OpenBSD Secure Shell server (/etc/ssh/NOSERVER)"
19 # Configurable options:
20 KEYGEN=/usr/bin/ssh-keygen
21 RSA1_KEY=/etc/ssh/ssh_host_key
22 RSA_KEY=/etc/ssh/ssh_host_rsa_key
23 DSA_KEY=/etc/ssh/ssh_host_dsa_key
27 test -f /etc/ssh/sshd_not_to_be_run && exit 0
28 if ! test -f $RSA1_KEY ; then
29 echo "Generating SSH1 RSA host key..."
30 $KEYGEN -t rsa1 -f $RSA1_KEY -C '' -N '' || exit 1
32 if ! test -f $RSA_KEY ; then
33 echo "Generating SSH RSA host key..."
34 $KEYGEN -t rsa -f $RSA_KEY -C '' -N '' || exit 1
36 if ! test -f $DSA_KEY ; then
37 echo "Generating SSH2 DSA host key..."
38 $KEYGEN -t dsa -f $DSA_KEY -C '' -N '' || exit 1
40 echo -n "Starting OpenBSD Secure Shell server: sshd"
41 start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
45 echo -n "Stopping OpenBSD Secure Shell server: sshd"
46 start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
51 test -f /etc/ssh/sshd_not_to_be_run && exit 0
52 echo -n "Reloading OpenBSD Secure Shell server's configuration"
53 start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
58 test -f /etc/ssh/sshd_not_to_be_run && exit 0
59 echo -n "Restarting OpenBSD Secure Shell server: sshd"
60 start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
62 start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
67 echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
73 ## END OF FILE #################################################################