522
|
1 #!/bin/sh |
|
2 set -e |
|
3 |
|
4 test "$1" = 'configure' || exit 0 |
|
5 |
|
6 if test ! -e /etc/dropbear/dropbear_rsa_host_key; then |
|
7 if test -f /etc/ssh/ssh_host_rsa_key; then |
|
8 echo "Converting existing OpenSSH RSA host key to Dropbear format." |
|
9 /usr/lib/dropbear/dropbearconvert openssh dropbear \ |
|
10 /etc/ssh/ssh_host_rsa_key /etc/dropbear/dropbear_rsa_host_key |
|
11 else |
|
12 echo "Generating Dropbear RSA key. Please wait." |
|
13 dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key |
|
14 fi |
|
15 fi |
|
16 if test ! -e /etc/dropbear/dropbear_dss_host_key; then |
|
17 if test -f /etc/ssh/ssh_host_dsa_key; then |
|
18 echo "Converting existing OpenSSH RSA host key to Dropbear format." |
|
19 /usr/lib/dropbear/dropbearconvert openssh dropbear \ |
|
20 /etc/ssh/ssh_host_dsa_key /etc/dropbear/dropbear_dss_host_key |
|
21 else |
|
22 echo "Generating Dropbear DSS key. Please wait." |
|
23 dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key |
|
24 fi |
|
25 fi |
|
26 if test ! -s /etc/default/dropbear; then |
|
27 # check whether OpenSSH seems to be installed. |
|
28 if test -x /usr/sbin/sshd; then |
|
29 cat <<EOT |
|
30 OpenSSH appears to be installed. Setting /etc/default/dropbear so that |
|
31 Dropbear will not start by default. Edit this file to change this behaviour. |
|
32 |
|
33 EOT |
|
34 cat >>/etc/default/dropbear <<EOT |
|
35 # disabled because OpenSSH is installed |
|
36 # change to NO_START=0 to enable Dropbear |
|
37 NO_START=1 |
|
38 |
|
39 EOT |
|
40 fi |
|
41 cat >>/etc/default/dropbear <<EOT |
|
42 # the TCP port that Dropbear listens on |
|
43 DROPBEAR_PORT=22 |
|
44 |
|
45 # any additional arguments for Dropbear |
|
46 DROPBEAR_EXTRA_ARGS= |
|
47 |
|
48 # specify an optional banner file containing a message to be |
|
49 # sent to clients before they connect, such as "/etc/issue.net" |
|
50 DROPBEAR_BANNER="" |
|
51 |
|
52 # RSA hostkey file (default: /etc/dropbear/dropbear_rsa_host_key) |
|
53 #DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key" |
|
54 |
|
55 # DSS hostkey file (default: /etc/dropbear/dropbear_dss_host_key) |
|
56 #DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key" |
|
57 |
|
58 # Receive window size - this is a tradeoff between memory and |
|
59 # network performance |
|
60 DROPBEAR_RECEIVE_WINDOW=65536 |
|
61 EOT |
|
62 fi |
|
63 |
|
64 if test -x /etc/init.d/dropbear; then |
|
65 update-rc.d dropbear defaults >/dev/null |
|
66 if test -x /usr/sbin/invoke-rc.d; then |
|
67 invoke-rc.d dropbear restart |
|
68 else |
|
69 /etc/init.d/dropbear restart |
|
70 fi |
|
71 fi |
|
72 |
|
73 if test -n "$2" && dpkg --compare-versions "$2" lt '0.50-4' && |
|
74 update-service --check dropbear 2>/dev/null; then |
|
75 update-service --remove /etc/dropbear 2>/dev/null || : |
|
76 sleep 6 |
|
77 rm -rf /var/run/dropbear /var/run/dropbear.log |
|
78 update-service --add /etc/dropbear || : |
|
79 fi |