]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/openssh/S50sshd
d3abf7c8ead35acffc7a30571c2902e635e3b82b
[coffee/buildroot.git] / package / openssh / S50sshd
1 #!/bin/sh
2 #
3 # sshd        Starts sshd.
4 #
5
6 # Make sure the ssh-keygen progam exists
7 [ -f /usr/bin/ssh-keygen ] || exit 0
8
9 # Check for the SSH1 RSA key
10 if [ ! -f /etc/ssh_host_key ] ; then
11         echo Generating RSA Key...
12         /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh_host_key -C '' -N ''
13 fi
14
15 # Check for the SSH2 RSA key
16 if [ ! -f /etc/ssh_host_rsa_key ] ; then
17         echo Generating RSA Key...
18         /usr/bin/ssh-keygen -t rsa -f /etc/ssh_host_rsa_key -C '' -N ''
19 fi
20
21 # Check for the SSH2 DSA key
22 if [ ! -f /etc/ssh_host_dsa_key ] ; then
23         echo Generating DSA Key...
24         echo
25         /usr/bin/ssh-keygen -t dsa -f /etc/ssh_host_dsa_key -C '' -N ''
26 fi
27
28 # Check for the SSH2 ECDSA key
29 if [ ! -f /etc/ssh_host_ecdsa_key ]; then
30         echo Generating ECDSA Key...
31         echo
32         /usr/bin/ssh-keygen -t ecdsa -f /etc/ssh_host_ecdsa_key -C '' -N ''
33 fi
34
35 # Check for the ed25519 key
36 if [ ! -f /etc/ssh_host_ed25519_key ]; then
37         echo Generating ed25519 Key...
38         echo
39         /usr/bin/ssh-keygen -t ed25519 -f /etc/ssh_host_ed25519_key -C '' -N ''
40 fi
41
42 umask 077
43
44 start() {
45         echo -n "Starting sshd: "
46         /usr/sbin/sshd
47         touch /var/lock/sshd
48         echo "OK"
49 }
50 stop() {
51         echo -n "Stopping sshd: "
52         killall sshd
53         rm -f /var/lock/sshd
54         echo "OK"
55 }
56 restart() {
57         stop
58         start
59 }
60
61 case "$1" in
62   start)
63         start
64         ;;
65   stop)
66         stop
67         ;;
68   restart|reload)
69         restart
70         ;;
71   *)
72         echo "Usage: $0 {start|stop|restart}"
73         exit 1
74 esac
75
76 exit $?
77