2006-02-23 15:26:10 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# /etc/rc.d/sshd: start/stop ssh daemon
|
|
|
|
#
|
|
|
|
|
2015-06-26 11:55:28 +02:00
|
|
|
SSD=/sbin/start-stop-daemon
|
|
|
|
PROG=/usr/sbin/sshd
|
|
|
|
PID=/var/run/sshd.pid
|
|
|
|
KEYGEN=/usr/bin/ssh-keygen
|
|
|
|
SSHDIR=/etc/ssh
|
|
|
|
|
|
|
|
create_keys() {
|
|
|
|
if [ ! -f $SSHDIR/ssh_host_rsa_key ]; then
|
|
|
|
$KEYGEN -q -t rsa -b 2048 -N "" -f $SSHDIR/ssh_host_rsa_key
|
2006-02-23 15:26:10 +00:00
|
|
|
fi
|
2015-06-26 11:55:28 +02:00
|
|
|
if [ ! -f $SSHDIR/ssh_host_dsa_key ]; then
|
|
|
|
$KEYGEN -q -t dsa -N "" -f $SSHDIR/ssh_host_dsa_key
|
2011-01-24 16:58:23 +01:00
|
|
|
fi
|
2015-06-26 11:55:28 +02:00
|
|
|
if [ ! -f $SSHDIR/ssh_host_ecdsa_key ]; then
|
|
|
|
$KEYGEN -q -t ecdsa -b 521 -N "" -f $SSHDIR/ssh_host_ecdsa_key
|
2014-02-01 15:06:20 +01:00
|
|
|
fi
|
2015-06-26 11:55:28 +02:00
|
|
|
if [ ! -f $SSHDIR/ssh_host_ed25519_key ]; then
|
|
|
|
$KEYGEN -q -t ed25519 -N "" -f $SSHDIR/ssh_host_ed25519_key
|
2015-02-24 14:19:44 +01:00
|
|
|
fi
|
2015-06-26 11:55:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
start)
|
|
|
|
create_keys
|
|
|
|
$SSD --start --pidfile $PID --exec $PROG
|
2006-02-23 15:26:10 +00:00
|
|
|
;;
|
|
|
|
stop)
|
2015-06-26 11:55:28 +02:00
|
|
|
$SSD --stop --retry 10 --pidfile $PID
|
2006-02-23 15:26:10 +00:00
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
2015-06-26 11:55:28 +02:00
|
|
|
status)
|
|
|
|
$SSD --status --pidfile $PID
|
|
|
|
case $? in
|
|
|
|
0) echo "$PROG is running with pid $(cat $PID)" ;;
|
|
|
|
1) echo "$PROG is not running but the pid file $PID exists" ;;
|
|
|
|
3) echo "$PROG is not running" ;;
|
|
|
|
4) echo "Unable to determine the program status" ;;
|
|
|
|
esac
|
|
|
|
;;
|
2006-02-23 15:26:10 +00:00
|
|
|
*)
|
2015-06-26 11:55:28 +02:00
|
|
|
echo "usage: $0 [start|stop|restart|status]"
|
2006-02-23 15:26:10 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# End of file
|