summaryrefslogtreecommitdiffstats
path: root/projectroot
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2020-08-08 10:34:55 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2020-08-14 14:24:52 +0200
commit0a4f1ee4ed231a4e95dad545ba52ed2679e122ec (patch)
tree9fcaf59ba43ea55cac15e58756313163ba38057d /projectroot
parent96e952f118896288343003866c02384f09e7a28b (diff)
downloadptxdist-0a4f1ee4ed231a4e95dad545ba52ed2679e122ec.tar.gz
ptxdist-0a4f1ee4ed231a4e95dad545ba52ed2679e122ec.tar.xz
openssh/rc-once: deduplicate some data
The create_keys() function passed the key type three times. Now it's only passed once. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Message-Id: <20200808083456.26483-1-u.kleine-koenig@pengutronix.de> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'projectroot')
-rw-r--r--projectroot/etc/rc.once.d/openssh25
1 files changed, 11 insertions, 14 deletions
diff --git a/projectroot/etc/rc.once.d/openssh b/projectroot/etc/rc.once.d/openssh
index 4a3c594cc..bfec70641 100644
--- a/projectroot/etc/rc.once.d/openssh
+++ b/projectroot/etc/rc.once.d/openssh
@@ -18,32 +18,29 @@ host_keys_required() {
}
create_key() {
- msg="$1"
+ keytype="$1"
+ prettykeytype="$(echo $_type | tr a-z A-Z)"
shift
hostkeys="$1"
shift
- file="$1"
- shift
+
+ file="/etc/ssh/ssh_host_${keytype}_key"
if echo "$hostkeys" | grep -x "$file" >/dev/null; then
- echo "$msg; this may take some time ..."
+ echo "Create $prettykeytype key; this may take some time ..."
rm -f $file &&
- ssh-keygen -q -f "$file" -N '' "$@" || return
- echo "$msg; done."
+ ssh-keygen -q -f "$file" -N '' -t "$keytype" "$@" || return
+ echo "Created $prettykeytype key."
fi
}
create_keys() {
hostkeys="$(host_keys_required)"
- create_key "Creating DSA key" \
- "$hostkeys" /etc/ssh/ssh_host_dsa_key -t dsa &&
- create_key "Creating ECDSA key" \
- "$hostkeys" /etc/ssh/ssh_host_ecdsa_key -t ecdsa &&
- create_key "Creating ED25519 key" \
- "$hostkeys" /etc/ssh/ssh_host_ed25519_key -t ed25519 &&
- create_key "Creating RSA key" \
- "$hostkeys" /etc/ssh/ssh_host_rsa_key -t rsa -b 4096
+ create_key "dsa" "$hostkeys" &&
+ create_key "ecdsa" "$hostkeys" &&
+ create_key "ed25519" "$hostkeys" &&
+ create_key "rsa" "$hostkeys" -b 4096
}
if ! create_keys; then