wok view openssh/stuff/openssh @ rev 20649
retawq: regenerate mo files (Aleksej)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jan 12 12:21:17 2019 +0100 (2019-01-12) |
parents | 6a8b83dd1456 |
children | 9096d6788292 |
line source
1 #!/bin/sh
2 # /etc/init.d/openssh : Start, stop and restart OpenSSH server on SliTaz, at
3 # boot time or with the command line.
4 #
5 # To start OpenSSH server at boot time, just put openssh in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
7 #
8 . /etc/init.d/rc.functions
9 . /etc/daemons.conf
11 NAME=OpenSSH
12 DESC="$(_ '%s server' OpenSSH)"
13 DAEMON=/usr/sbin/sshd
14 OPTIONS=$OPENSSH_OPTIONS
15 PIDFILE=/var/run/sshd.pid
17 [ -d /var/run/sshd ] || mkdir -p /var/run/sshd
19 case "$1" in
20 start)
21 # We need rsa and dsa host key file to start dropbear.
22 for type in rsa dsa ecdsa ; do
23 [ -s /etc/ssh/ssh_host_${type}_key ] && continue
24 _ 'Generating OpenSSH %s key... ' $type
25 ssh-keygen -t $type -f /etc/ssh/ssh_host_${type}_key -C '' -N ''
26 done
27 if active_pidfile $PIDFILE sshd ; then
28 _ '%s is already running.' $NAME
29 exit 1
30 fi
31 if [ -n "$(which iptables)" ] && ! iptables -L | grep 'tcp dpt:ssh ' ; then
32 tcp22new='iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent'
33 $tcp22new --set --name DEFAULT --rsource
34 limit='--seconds 300 --hitcount 5 --name DEFAULT --rsource'
35 $tcp22new --update $limit -j LOG --log-prefix "SSH-Bruteforce : "
36 $tcp22new --update $limit -j DROP
37 fi
38 action 'Starting %s: %s...' "$DESC" $NAME
39 $DAEMON $OPTIONS
40 status
41 ;;
42 stop)
43 if ! active_pidfile $PIDFILE sshd ; then
44 _ '%s is not running.' $NAME
45 exit 1
46 fi
47 action 'Stopping %s: %s...' "$DESC" $NAME
48 kill $(cat $PIDFILE)
49 status
50 ;;
51 restart)
52 if ! active_pidfile $PIDFILE sshd ; then
53 _ '%s is not running.' $NAME
54 exit 1
55 fi
56 action 'Restarting %s: %s...' "$DESC" $NAME
57 kill $(cat $PIDFILE)
58 sleep 2
59 $DAEMON $OPTIONS
60 status
61 ;;
62 *)
63 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]"
64 newline
65 exit 1
66 ;;
67 esac
69 exit 0