From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH] openssh: improve rc.once script to support locations other than /etc/ssh
Date: Wed, 18 Dec 2013 16:13:25 +0100 [thread overview]
Message-ID: <1387379605-6643-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
This is done by parsing the sshd_config using awk for the location of
the key files being used.
Note that the dependency on awk is a weak one because if awk isn't
available the script simply falls back to the default location.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
generic/etc/rc.once.d/openssh | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/generic/etc/rc.once.d/openssh b/generic/etc/rc.once.d/openssh
index 83e6e37..fea8472 100644
--- a/generic/etc/rc.once.d/openssh
+++ b/generic/etc/rc.once.d/openssh
@@ -2,13 +2,15 @@
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"
+get_default_key() {
+ key_type=$1
+ sshd_config="/etc/ssh/sshd_config"
+
+ awk -v type="$key_type" '/^HostKey/ && match($2, "/ssh_host_" type "_key$") { print $2; found=1 } END { exit !found }' "$sshd_config" || echo "/etc/ssh/ssh_host_${key_type}_key"
+}
-test -n "$OPENSSH_RSAKEY" || \
- OPENSSH_RSAKEY=$OPENSSH_RSAKEY_DEFAULT
-test -n "$OPENSSH_DSAKEY" || \
- OPENSSH_DSAKEY=$OPENSSH_DSAKEY_DEFAULT
+OPENSSH_RSAKEY="$(get_default_key rsa)"
+OPENSSH_DSAKEY="$(get_default_key dsa)"
gen_key() {
--
1.8.4.4
--
ptxdist mailing list
ptxdist@pengutronix.de
next reply other threads:[~2013-12-18 15:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 15:13 Uwe Kleine-König [this message]
2014-01-06 11:07 ` Michael Olbrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387379605-6643-1-git-send-email-u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox