From: Harald Seiler <hws@denx.de>
To: Henning Schild <henning.schild@siemens.com>
Cc: isar-users@googlegroups.com
Subject: [PATCH v2] meta: Add recipe to regenerate ssh host keys
Date: Tue, 02 Oct 2018 10:43:43 +0200 [thread overview]
Message-ID: <4ee60044614a050c4ad7e9996f8c051391885bc7.camel@denx.de> (raw)
In-Reply-To: <20180926103138.1241c7f1@md1pvb1c.ad001.siemens.net>
sshd-regen-keys is a systemd unit that will run
at first boot and force sshd to generate new
host keys.
This prevents all devices using the same keys.
Signed-off-by: Harald Seiler <hws@denx.de>
---
meta/recipes-support/sshd-regen-keys/files/postinst | 4 ++++
.../sshd-regen-keys/files/sshd-regen-keys.service | 19 +++++++++++++++++++
.../sshd-regen-keys/sshd-regen-keys_0.1.bb | 15 +++++++++++++++
3 files changed, 38 insertions(+)
create mode 100644 meta/recipes-support/sshd-regen-keys/files/postinst
create mode 100644 meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
create mode 100644 meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.1.bb
diff --git a/meta/recipes-support/sshd-regen-keys/files/postinst b/meta/recipes-support/sshd-regen-keys/files/postinst
new file mode 100644
index 0000000..ae722a7
--- /dev/null
+++ b/meta/recipes-support/sshd-regen-keys/files/postinst
@@ -0,0 +1,4 @@
+#!/bin/sh
+set -e
+
+systemctl enable sshd-regen-keys.service
diff --git a/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
new file mode 100644
index 0000000..3b8231f
--- /dev/null
+++ b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Regenerate sshd host keys
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=systemd-remount-fs.service
+Before=shutdown.target sshd.service
+ConditionPathIsReadWrite=/etc
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+Environment=DEBIAN_FRONTEND=noninteractive
+ExecStart=/bin/sh -c "rm -v /etc/ssh/ssh_host_*_key*; dpkg-reconfigure openssh-server"
+ExecStartPost=-/bin/systemctl disable sshd-regen-keys.service
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=sysinit.target
diff --git a/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.1.bb b/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.1.bb
new file mode 100644
index 0000000..06e0cc4
--- /dev/null
+++ b/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.1.bb
@@ -0,0 +1,15 @@
+# This software is a part of ISAR.
+
+DESCRIPTION = "Systemd service to regenerate sshd keys"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+DEBIAN_DEPENDS = "openssh-server, systemd"
+
+SRC_URI = "file://postinst \
+ file://sshd-regen-keys.service"
+
+inherit dpkg-raw
+
+do_install() {
+ sudo install -v -d -m 755 "${D}/lib/systemd/system"
+ sudo install -v -m 644 "${WORKDIR}/sshd-regen-keys.service" "${D}/lib/systemd/system/sshd-regen-keys.service"
+}
next prev parent reply other threads:[~2018-10-02 8:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-25 15:53 [PATCH] " Harald Seiler
2018-09-26 8:31 ` Henning Schild
2018-10-02 8:43 ` Harald Seiler [this message]
2018-10-02 17:56 ` Henning Schild
2018-10-09 8:42 ` [PATCH v3] " Harald Seiler
2018-10-09 12:13 ` [PATCH v4] " Harald Seiler
2018-10-17 12:12 ` Maxim Yu. Osipov
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=4ee60044614a050c4ad7e9996f8c051391885bc7.camel@denx.de \
--to=hws@denx.de \
--cc=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
/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