summaryrefslogtreecommitdiffstats
path: root/generic/etc
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2010-02-12 11:07:46 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2010-04-20 10:10:29 +0200
commitdc40bf7e4d924345da9e6bde340ac487c11f9515 (patch)
treeb973a1b158e4ab15c66e4a276d6d8ce3c0964077 /generic/etc
parent36cf5b220e8b5f191342d13ed2d069d2bbca77d5 (diff)
downloadptxdist-dc40bf7e4d924345da9e6bde340ac487c11f9515.tar.gz
ptxdist-dc40bf7e4d924345da9e6bde340ac487c11f9515.tar.xz
[openssh] use rc-once to create server keys
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'generic/etc')
-rw-r--r--generic/etc/init.d/openssh37
-rw-r--r--generic/etc/rc.once.d/openssh33
2 files changed, 33 insertions, 37 deletions
diff --git a/generic/etc/init.d/openssh b/generic/etc/init.d/openssh
index ee242d84c..b65880e5d 100644
--- a/generic/etc/init.d/openssh
+++ b/generic/etc/init.d/openssh
@@ -5,48 +5,11 @@ DAEMON=/usr/sbin/sshd
NAME=sshd
PIDFILE=/var/run/sshd.pid
-OPENSSH_RSAKEY_DEFAULT="/etc/ssh/ssh_host_rsa_key"
-OPENSSH_DSAKEY_DEFAULT="/etc/ssh/ssh_host_dsa_key"
-
-. /lib/init/initmethod-bbinit-functions.sh
-
-test -n "$OPENSSH_RSAKEY" || \
- OPENSSH_RSAKEY=$OPENSSH_RSAKEY_DEFAULT
-test -n "$OPENSSH_DSAKEY" || \
- OPENSSH_DSAKEY=$OPENSSH_DSAKEY_DEFAULT
-
-gen_key() {
-
- key_type=$1
- key_file=$2
-
- mount_root_rw || exit
- rm -f $key_file > /dev/null 2>&1
-
- echo -n "generating $key_type key..."
- ssh-keygen -t $key_type -f $key_file -N "" > /dev/null 2>&1
-
- if [ "$?" = "0" ]; then
- echo "done"
- else
- echo "failed"
- mount_root_restore
- exit 1
- fi
-
- mount_root_restore || exit
-}
-
-
case "$1" in
start)
mkdir -p /var/run/sshd
- # create keys if necessary
- [ \! -f "$OPENSSH_RSAKEY" ] && gen_key rsa "$OPENSSH_RSAKEY"
- [ \! -f "$OPENSSH_DSAKEY" ] && gen_key dsa "$OPENSSH_DSAKEY"
-
echo -n "starting sshd..."
start-stop-daemon -S -x "$DAEMON" -p "$PIDFILE" > /dev/null 2>&1
if [ "$?" = "0" ]; then
diff --git a/generic/etc/rc.once.d/openssh b/generic/etc/rc.once.d/openssh
new file mode 100644
index 000000000..83e6e37de
--- /dev/null
+++ b/generic/etc/rc.once.d/openssh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+OPENSSH_RSAKEY_DEFAULT="/etc/ssh/ssh_host_rsa_key"
+OPENSSH_DSAKEY_DEFAULT="/etc/ssh/ssh_host_dsa_key"
+
+test -n "$OPENSSH_RSAKEY" || \
+ OPENSSH_RSAKEY=$OPENSSH_RSAKEY_DEFAULT
+test -n "$OPENSSH_DSAKEY" || \
+ OPENSSH_DSAKEY=$OPENSSH_DSAKEY_DEFAULT
+
+gen_key() {
+
+ key_type=$1
+ key_file=$2
+
+ rm -f $key_file > /dev/null 2>&1
+
+ echo -n "generating $key_type key..."
+ ssh-keygen -t $key_type -f $key_file -N "" > /dev/null 2>&1
+
+ if [ "$?" = "0" ]; then
+ echo "done"
+ else
+ echo "failed"
+ exit 1
+ fi
+}
+
+gen_key rsa "$OPENSSH_RSAKEY"
+gen_key dsa "$OPENSSH_DSAKEY"
+