All of lore.kernel.org
 help / color / mirror / Atom feed
From: Norbert Lange <nolange79@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 3/4] package/openssh: seperate sd service for host key generation
Date: Sat,  6 Jun 2020 00:59:03 +0200	[thread overview]
Message-ID: <20200605225905.14082-3-nolange79@gmail.com> (raw)
In-Reply-To: <20200605225905.14082-1-nolange79@gmail.com>

split out generationg of host keys into an optional service
that can easily be removed or deactivated.

Signed-off-by: Norbert Lange <nolange79@gmail.com>
---
 package/openssh/openssh.mk               |  5 +++--
 package/openssh/sshd-host-keygen.service | 20 ++++++++++++++++++++
 package/openssh/sshd.service             |  1 -
 3 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 package/openssh/sshd-host-keygen.service

diff --git a/package/openssh/openssh.mk b/package/openssh/openssh.mk
index d425db1428..6b3ee1f5f4 100644
--- a/package/openssh/openssh.mk
+++ b/package/openssh/openssh.mk
@@ -114,8 +114,9 @@ endef
 OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_INSTALL_SERVER_PROGRAMS
 
 define OPENSSH_INSTALL_INIT_SYSTEMD
-	$(INSTALL) -D -m 644 package/openssh/sshd.service \
-		$(TARGET_DIR)/usr/lib/systemd/system/sshd.service
+	mkdir $(TARGET_DIR)/usr/lib/systemd/system
+	$(INSTALL) -m 644 package/openssh/sshd*.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/
 	$(OPENSSH_INSTALL_SYSTEMD_SYSUSERS)
 endef
 
diff --git a/package/openssh/sshd-host-keygen.service b/package/openssh/sshd-host-keygen.service
new file mode 100644
index 0000000000..058e671c44
--- /dev/null
+++ b/package/openssh/sshd-host-keygen.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=SSH Key Generation
+Before=sshd.service
+
+ConditionPathExists=|!/etc/ssh/ssh_host_dsa_key
+ConditionPathExists=|!/etc/ssh/ssh_host_dsa_key.pub
+ConditionPathExists=|!/etc/ssh/ssh_host_ecdsa_key
+ConditionPathExists=|!/etc/ssh/ssh_host_ecdsa_key.pub
+ConditionPathExists=|!/etc/ssh/ssh_host_ed25519_key
+ConditionPathExists=|!/etc/ssh/ssh_host_ed25519_key.pub
+ConditionPathExists=|!/etc/ssh/ssh_host_rsa_key
+ConditionPathExists=|!/etc/ssh/ssh_host_rsa_key.pub
+
+[Service]
+ExecStart=/usr/bin/ssh-keygen -A
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=sshd.service
diff --git a/package/openssh/sshd.service b/package/openssh/sshd.service
index 715bd3f7eb..797e249d8d 100644
--- a/package/openssh/sshd.service
+++ b/package/openssh/sshd.service
@@ -4,7 +4,6 @@ Documentation=man:sshd(8) man:sshd_config(5)
 After=network.target auditd.service
 
 [Service]
-ExecStartPre=/usr/bin/ssh-keygen -A
 ExecStartPre=/usr/sbin/sshd -t
 ExecStart=/usr/sbin/sshd -D
 ExecReload=/usr/sbin/sshd -t
-- 
2.26.2

  parent reply	other threads:[~2020-06-05 22:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 22:59 [Buildroot] [PATCH 1/4] package/openssh: Depend on libaudit if available Norbert Lange
2020-06-05 22:59 ` [Buildroot] [PATCH 2/4] package/openssh: improve integration for systemd Norbert Lange
2020-06-06 20:31   ` Thomas Petazzoni
2020-06-07 10:54   ` Jérémy ROSEN
2020-06-07 19:03     ` Norbert Lange
2020-06-07 19:16       ` Jérémy ROSEN
2020-06-07 19:24         ` Norbert Lange
2020-06-07 19:42           ` Jérémy ROSEN
2020-06-11  0:04             ` Norbert Lange
2020-06-11  6:14               ` Jérémy ROSEN
2020-06-05 22:59 ` Norbert Lange [this message]
2020-06-07 10:44   ` [Buildroot] [PATCH 3/4] package/openssh: seperate sd service for host key generation Jérémy ROSEN
2020-06-07 18:55     ` Norbert Lange
2020-06-07 19:09       ` Jérémy ROSEN
2020-06-05 22:59 ` [Buildroot] [PATCH 4/4] package/openssh: add sd socket-activated ssh daemon services Norbert Lange
2020-06-07 11:06   ` Jérémy ROSEN
2020-06-07 19:10     ` Norbert Lange
2020-06-07 19:31       ` Jérémy ROSEN
2020-06-07 19:45         ` Norbert Lange
2020-06-07 21:30           ` Norbert Lange
2020-06-07 21:43             ` Jérémy ROSEN
2020-06-06 20:29 ` [Buildroot] [PATCH 1/4] package/openssh: Depend on libaudit if available Thomas Petazzoni

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=20200605225905.14082-3-nolange79@gmail.com \
    --to=nolange79@gmail.com \
    --cc=buildroot@busybox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.