public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] openssh: add variable for key path
@ 2026-01-02 11:27 Patrick Vogelaar
  2026-01-08 14:00 ` [OE-core] " Paul Barker
  2026-01-25  9:15 ` [PATCH v2] " Patrick Vogelaar
  0 siblings, 2 replies; 6+ messages in thread
From: Patrick Vogelaar @ 2026-01-02 11:27 UTC (permalink / raw)
  To: openembedded-core; +Cc: Patrick Vogelaar

This patch adds a variable for the key directory path. This is especially
useful when working with a read-only file system where you want to
specify the location e.g. on a r/w partition. To be consistent, the
change was also done for the read write path.

For changing the path simply create a bbappend and override the
variable.

Signed-off-by: Patrick Vogelaar <patrick.vogelaar.dev@mailbox.org>
---
 .../openssh/openssh_10.2p1.bb                    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
index 866129573f..e319f4ac24 100644
--- a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
@@ -99,6 +99,10 @@ CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
 # We don't want to depend on libblockfile
 CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
 
+# This allows overriding the key location in a bbappend
+RO_SSH_KEY_DIR ?= "/var/run/ssh"
+SSH_KEY_DIR ?= "/etc/ssh"
+
 do_configure:prepend () {
 	export LD="${CC}"
 	install -m 0600 ${UNPACKDIR}/sshd_config ${B}/
@@ -113,24 +117,24 @@ sshd_hostkey_setup() {
 	# Enable specific ssh host keys
 	sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-rsa','true','false',d)}; then
-		echo "HostKey /etc/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
+		echo "HostKey ${SSH_KEY_DIR}/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ecdsa','true','false',d)}; then
-		echo "HostKey /etc/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
+		echo "HostKey ${SSH_KEY_DIR}/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ed25519','true','false',d)}; then
-		echo "HostKey /etc/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config
+		echo "HostKey ${SSH_KEY_DIR}/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config
 	fi
 
 	sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-rsa','true','false',d)}; then
-		echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
+		echo "HostKey ${RO_SSH_KEY_DIR}/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ecdsa','true','false',d)}; then
-		echo "HostKey /var/run/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
+		echo "HostKey ${RO_SSH_KEY_DIR}/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ed25519','true','false',d)}; then
-		echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
+		echo "HostKey ${RO_SSH_KEY_DIR}/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
 	fi
 }
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] openssh: add variable for key path
  2026-01-02 11:27 [PATCH] openssh: add variable for key path Patrick Vogelaar
@ 2026-01-08 14:00 ` Paul Barker
  2026-01-25  9:15 ` [PATCH v2] " Patrick Vogelaar
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Barker @ 2026-01-08 14:00 UTC (permalink / raw)
  To: patrick.vogelaar.dev, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3970 bytes --]

On Fri, 2026-01-02 at 12:27 +0100, Patrick Vogelaar via
lists.openembedded.org wrote:
> This patch adds a variable for the key directory path. This is especially
> useful when working with a read-only file system where you want to
> specify the location e.g. on a r/w partition. To be consistent, the
> change was also done for the read write path.
> 
> For changing the path simply create a bbappend and override the
> variable.
> 
> Signed-off-by: Patrick Vogelaar <patrick.vogelaar.dev@mailbox.org>
> ---
>  .../openssh/openssh_10.2p1.bb                    | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> index 866129573f..e319f4ac24 100644
> --- a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> +++ b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> @@ -99,6 +99,10 @@ CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
>  # We don't want to depend on libblockfile
>  CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
>  
> +# This allows overriding the key location in a bbappend
> +RO_SSH_KEY_DIR ?= "/var/run/ssh"
> +SSH_KEY_DIR ?= "/etc/ssh"

The naming here is very easy to confuse, but I guess it's to match with
the 'sshd_config' and 'sshd_config_readonly' filenames. I think we
should be explicit in the RO case that we're talking about the read-only
configuration though. And we'd prefer this as a suffix instead of a
prefix.

Oh, and we should make it clear that this is specific to openssh, then
these variables could be set from a config file instead of just a
bbappend. And make it clear that it's for the host keys while we're at
it.

Many 'and's there!

So, I suggest we use:

  OPENSSH_HOST_KEY_DIR
  OPENSSH_HOST_KEY_DIR_READONLY_CONFIG

> +
>  do_configure:prepend () {
>  	export LD="${CC}"
>  	install -m 0600 ${UNPACKDIR}/sshd_config ${B}/
> @@ -113,24 +117,24 @@ sshd_hostkey_setup() {
>  	# Enable specific ssh host keys
>  	sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config
>  	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-rsa','true','false',d)}; then
> -		echo "HostKey /etc/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
> +		echo "HostKey ${SSH_KEY_DIR}/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
>  	fi
>  	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ecdsa','true','false',d)}; then
> -		echo "HostKey /etc/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
> +		echo "HostKey ${SSH_KEY_DIR}/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
>  	fi
>  	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ed25519','true','false',d)}; then
> -		echo "HostKey /etc/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config
> +		echo "HostKey ${SSH_KEY_DIR}/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config
>  	fi
>  
>  	sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
>  	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-rsa','true','false',d)}; then
> -		echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
> +		echo "HostKey ${RO_SSH_KEY_DIR}/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
>  	fi
>  	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ecdsa','true','false',d)}; then
> -		echo "HostKey /var/run/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
> +		echo "HostKey ${RO_SSH_KEY_DIR}/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
>  	fi
>  	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ed25519','true','false',d)}; then
> -		echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
> +		echo "HostKey ${RO_SSH_KEY_DIR}/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
>  	fi
>  }

Best regards,

-- 
Paul Barker


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] openssh: add variable for key path
  2026-01-02 11:27 [PATCH] openssh: add variable for key path Patrick Vogelaar
  2026-01-08 14:00 ` [OE-core] " Paul Barker
@ 2026-01-25  9:15 ` Patrick Vogelaar
  2026-01-29 11:17   ` [OE-core] " Antonin Godard
  1 sibling, 1 reply; 6+ messages in thread
From: Patrick Vogelaar @ 2026-01-25  9:15 UTC (permalink / raw)
  To: patrick.vogelaar.dev; +Cc: openembedded-core, paul

This patch adds a variable for the key directory path. This is especially
useful when working with a read-only file system where you want to
specify the location e.g. on a r/w partition. To be consistent, the
change was also done for the read write path.

For changing the path simply create a bbappend and override the
variable.

Signed-off-by: Patrick Vogelaar <patrick.vogelaar.dev@mailbox.org>
---
 .../openssh/openssh_10.2p1.bb                    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
index 866129573f..d8ea487ae3 100644
--- a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
@@ -99,6 +99,10 @@ CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
 # We don't want to depend on libblockfile
 CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
 
+# This allows overriding the key location
+OPENSSH_HOST_KEY_DIR_READONLY_CONFIG ?= "/var/run/ssh"
+OPENSSH_HOST_KEY_DIR ?= "/etc/ssh"
+
 do_configure:prepend () {
 	export LD="${CC}"
 	install -m 0600 ${UNPACKDIR}/sshd_config ${B}/
@@ -113,24 +117,24 @@ sshd_hostkey_setup() {
 	# Enable specific ssh host keys
 	sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-rsa','true','false',d)}; then
-		echo "HostKey /etc/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
+		echo "HostKey ${OPENSSH_HOST_KEY_DIR}/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ecdsa','true','false',d)}; then
-		echo "HostKey /etc/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
+		echo "HostKey ${OPENSSH_HOST_KEY_DIR}/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ed25519','true','false',d)}; then
-		echo "HostKey /etc/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config
+		echo "HostKey ${OPENSSH_HOST_KEY_DIR}/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config
 	fi
 
 	sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-rsa','true','false',d)}; then
-		echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
+		echo "HostKey ${OPENSSH_HOST_KEY_DIR_READONLY_CONFIG}/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ecdsa','true','false',d)}; then
-		echo "HostKey /var/run/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
+		echo "HostKey ${OPENSSH_HOST_KEY_DIR_READONLY_CONFIG}/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
 	fi
 	if ${@bb.utils.contains('PACKAGECONFIG','hostkey-ed25519','true','false',d)}; then
-		echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
+		echo "HostKey ${OPENSSH_HOST_KEY_DIR_READONLY_CONFIG}/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
 	fi
 }
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH v2] openssh: add variable for key path
  2026-01-25  9:15 ` [PATCH v2] " Patrick Vogelaar
@ 2026-01-29 11:17   ` Antonin Godard
  2026-01-31 10:01     ` patrick.vogelaar.dev
  0 siblings, 1 reply; 6+ messages in thread
From: Antonin Godard @ 2026-01-29 11:17 UTC (permalink / raw)
  To: patrick.vogelaar.dev; +Cc: openembedded-core, paul

Hi,

On Sun Jan 25, 2026 at 10:15 AM CET, Patrick Vogelaar via lists.openembedded.org wrote:
> This patch adds a variable for the key directory path. This is especially
> useful when working with a read-only file system where you want to
> specify the location e.g. on a r/w partition. To be consistent, the
> change was also done for the read write path.
>
> For changing the path simply create a bbappend and override the
> variable.
>
> Signed-off-by: Patrick Vogelaar <patrick.vogelaar.dev@mailbox.org>
> ---
>  .../openssh/openssh_10.2p1.bb                    | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> index 866129573f..d8ea487ae3 100644
> --- a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> +++ b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> @@ -99,6 +99,10 @@ CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
>  # We don't want to depend on libblockfile
>  CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
>  
> +# This allows overriding the key location
> +OPENSSH_HOST_KEY_DIR_READONLY_CONFIG ?= "/var/run/ssh"
> +OPENSSH_HOST_KEY_DIR ?= "/etc/ssh"

Thanks for the patch, it was merged in master. As a follow-up, could you
send patches to document these variables in
https://git.yoctoproject.org/yocto-docs/tree/documentation/ref-manual/variables.rst?

And add a note here
https://git.yoctoproject.org/yocto-docs/tree/documentation/migration-guides/release-notes-6.0.rst#n24?

Thanks!
Antonin

-- 
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH v2] openssh: add variable for key path
  2026-01-29 11:17   ` [OE-core] " Antonin Godard
@ 2026-01-31 10:01     ` patrick.vogelaar.dev
  2026-02-02  9:46       ` Antonin Godard
  0 siblings, 1 reply; 6+ messages in thread
From: patrick.vogelaar.dev @ 2026-01-31 10:01 UTC (permalink / raw)
  To: Antonin Godard; +Cc: openembedded-core, paul

Hi Antonin,

> Antonin Godard <antonin.godard@bootlin.com> hat am 29.01.2026 12:17 CET geschrieben:
> 
>  
> Hi,
> 
> On Sun Jan 25, 2026 at 10:15 AM CET, Patrick Vogelaar via lists.openembedded.org wrote:
> > This patch adds a variable for the key directory path. This is especially
> > useful when working with a read-only file system where you want to
> > specify the location e.g. on a r/w partition. To be consistent, the
> > change was also done for the read write path.
> >
> > For changing the path simply create a bbappend and override the
> > variable.
> >
> > Signed-off-by: Patrick Vogelaar <patrick.vogelaar.dev@mailbox.org>
> > ---
> >  .../openssh/openssh_10.2p1.bb                    | 16 ++++++++++------
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> > index 866129573f..d8ea487ae3 100644
> > --- a/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> > +++ b/meta/recipes-connectivity/openssh/openssh_10.2p1.bb
> > @@ -99,6 +99,10 @@ CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
> >  # We don't want to depend on libblockfile
> >  CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
> >  
> > +# This allows overriding the key location
> > +OPENSSH_HOST_KEY_DIR_READONLY_CONFIG ?= "/var/run/ssh"
> > +OPENSSH_HOST_KEY_DIR ?= "/etc/ssh"
> 
> Thanks for the patch, it was merged in master. As a follow-up, could you
> send patches to document these variables in
> https://git.yoctoproject.org/yocto-docs/tree/documentation/ref-manual/variables.rst?
> 
> And add a note here
> https://git.yoctoproject.org/yocto-docs/tree/documentation/migration-guides/release-notes-6.0.rst#n24?

I will send a patch that documents the variable. But I don't know where to put it in the release notes. Can you guide me to the section where this would fit in.

> 
> Thanks!
> Antonin
> 
> -- 
> Antonin Godard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

Thanks
Patrick


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH v2] openssh: add variable for key path
  2026-01-31 10:01     ` patrick.vogelaar.dev
@ 2026-02-02  9:46       ` Antonin Godard
  0 siblings, 0 replies; 6+ messages in thread
From: Antonin Godard @ 2026-02-02  9:46 UTC (permalink / raw)
  To: patrick.vogelaar.dev; +Cc: openembedded-core, paul

Hi,

On Sat Jan 31, 2026 at 11:01 AM CET, Patrick Vogelaar via lists.openembedded.org wrote:
[...]
>> Thanks for the patch, it was merged in master. As a follow-up, could you
>> send patches to document these variables in
>> https://git.yoctoproject.org/yocto-docs/tree/documentation/ref-manual/variables.rst?
>> 
>> And add a note here
>> https://git.yoctoproject.org/yocto-docs/tree/documentation/migration-guides/release-notes-6.0.rst#n24?
>
> I will send a patch that documents the variable. But I don't know where to put it in the release notes. Can you guide me to the section where this would fit in.

Yes, it should be in this document:
https://git.yoctoproject.org/yocto-docs/tree/documentation/migration-guides/release-notes-6.0.rst

Under the bullet point "New variables"

Thanks,
Antonin

-- 
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-02  9:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-02 11:27 [PATCH] openssh: add variable for key path Patrick Vogelaar
2026-01-08 14:00 ` [OE-core] " Paul Barker
2026-01-25  9:15 ` [PATCH v2] " Patrick Vogelaar
2026-01-29 11:17   ` [OE-core] " Antonin Godard
2026-01-31 10:01     ` patrick.vogelaar.dev
2026-02-02  9:46       ` Antonin Godard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox