Skip to contentSkip to conversation

Issue with Installing openssh Package #kirkstone #systemd #yocto

DISCUSSION Nitesh D 3 participants 6 messages Apr 17, 2024

lore
Share & tools
lore

Nitesh D

author
#0 lore raw

Hello All,

This is my first time posting in the Yocto forum, so please bear with me (I'm a rookie).

One of my projects requires "openssh" to be installed in the image, but with all services disabled except for keeping sshdgenkeys.service running. I split it into two packages, but for some odd reason, "sshdgenkeys.service" is not getting installed on the image.

Here's my .bbappend file for openssh:

```
FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"

SYSTEMD_AUTO_ENABLE:${PN}-sshd = "disable"

PACKAGES =+ "${PN}-sshdgenkeys"
SYSTEMD_PACKAGES = "${PN}-sshdgenkeys"
SYSTEMD_SERVICE:${PN}-sshdgenkeys = "sshdgenkeys.service"
SYSTEMD_AUTO_ENABLE:${PN}-sshdgenkeys = "enable"

SRC_URI:append = " \
file://sshd_config \
"

do_install:append () {
install -d ${D}${sysconfdir}/ssh
install -m 0644 ${WORKDIR}/sshd_config ${D}${sysconfdir}/ssh/
install -m 0644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly
}

FILES:${PN}-sshd = " \
${sbindir}/sshd ${sysconfdir}/init.d/sshd \
${systemd_system_unitdir}/sshd.socket \
${systemd_system_unitdir}/[email protected] \
"
FILES:${PN}-sshdgenkeys = " \
${systemd_system_unitdir}/sshdgenkeys.service \
"
```

When I flash the image on my device, only the "${PN}-sshd" package is getting installed, and not "${PN}-sshdgenkeys".

I would appreciate a second pair of eyes on what I might be missing here.

Thanking you in advance.

Cheers,
Nitesh

#1 lore raw

openssh recipe (or its appends) does not control what gets installed into the image, only how openssh gets split into packages. To see what gets installed you need to find the image recipe and modify that as appropriate.

Alex

Quoted 58 lines · Nitesh D via lists.yoctoproject.org

Hello All,

This is my first time posting in the Yocto forum, so please bear with me (I'm a rookie).

One of my projects requires "openssh" to be installed in the image, but with all services disabled except for keeping sshdgenkeys.service running. I split it into two packages, but for some odd reason, "sshdgenkeys.service" is not getting installed on the image.

Here's my .bbappend file for openssh:

```
FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"

SYSTEMD_AUTO_ENABLE:${PN}-sshd = "disable"

PACKAGES =+ "${PN}-sshdgenkeys"
SYSTEMD_PACKAGES = "${PN}-sshdgenkeys"
SYSTEMD_SERVICE:${PN}-sshdgenkeys = "sshdgenkeys.service"
SYSTEMD_AUTO_ENABLE:${PN}-sshdgenkeys = "enable"

SRC_URI:append = " \
file://sshd_config \
"

do_install:append () {
    install -d ${D}${sysconfdir}/ssh
    install -m 0644 ${WORKDIR}/sshd_config ${D}${sysconfdir}/ssh/
    install -m 0644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly
}

FILES:${PN}-sshd = " \
${sbindir}/sshd ${sysconfdir}/init.d/sshd \
${systemd_system_unitdir}/sshd.socket \
${systemd_system_unitdir}/[email protected] \
"
FILES:${PN}-sshdgenkeys = " \
${systemd_system_unitdir}/sshdgenkeys.service \
"
```

When I flash the image on my device, only the "${PN}-sshd" package is getting installed, and not "${PN}-sshdgenkeys".

I would appreciate a second pair of eyes on what I might be missing here.

Thanking you in advance.

Cheers,
Nitesh

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62946): https://lists.yoctoproject.org/g/yocto/message/62946
Mute This Topic: https://lists.yoctoproject.org/mt/105575419/1686489
Mute #systemd:https://lists.yoctoproject.org/g/yocto/mutehashtag/systemd Mute #yocto:https://lists.yoctoproject.org/g/yocto/mutehashtag/yocto Mute #kirkstone:https://lists.yoctoproject.org/g/yocto/mutehashtag/kirkstone Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

author
#2 lore raw

Re: [yocto] Issue with Installing openssh Package #systemd #yocto #kirkstone

Alex,

Thanks for your prompt response.

Shouldn't "PACKAGES =+ "${PN}-sshdgenkeys"" take care of installing it on the image? Meaning my image recipe picks up everything from the packagegroup, which includes "openssh".

Part of the package is getting installed. When I flash the image on my device, only the "${PN}-sshd" package is getting installed, and not "${PN}-sshdgenkeys".

#3 lore raw

RE: [yocto] Issue with Installing openssh Package #systemd #yocto #kirkstone

From: [email protected] <[email protected]> On Behalf Of Nitesh D via lists.yoctoproject.org
Sent: Wednesday, April 17, 2024 14:21
To: Alexander Kanavin <[email protected]>; [email protected]
Subject: Re: [yocto] Issue with Installing openssh Package #systemd #yocto #kirkstone

Quoted 5 lines

Alex,

Thanks for your prompt response.

Shouldn't "PACKAGES =+ "${PN}-sshdgenkeys"" take care of installing it on the image? Meaning my image recipe picks up everything from the packagegroup, which includes "openssh".

“PACKAGES +=” only splits the files into additional package. New packages are not installed by default.
You need to install it via IMAGE_INSTALL (in image) or RDEPENDS/RRECOMMENDS (in recipe for package which is being installed already).

Quoted 2 lines

Part of the package is getting installed. When I flash the image on my device, only the "${PN}-sshd" package is getting installed, and not "${PN}-sshdgenkeys".

author
#4 lore raw

Re: [yocto] Issue with Installing openssh Package #systemd #yocto #kirkstone

Peter,

Ah ha! that jogged my memory... Even though openssh is in the IMAGE_INSTALL group I still need to add "openssh-sshdgenkeys" since I'm splitting the openssh package.

After adding "openssh-sshdgenkeys" into my image recipe service was installed as expected but it is not getting enabled, even though I explicitly specified to enable. Maybe I'm misunderstanding here...

SYSTEMD_AUTO_ENABLE:${PN}-sshdgenkeys = "enable"

For testing purposes, I started it manually:

root@localhost:~# systemctl status sshdgenkeys.service
* sshdgenkeys.service - OpenSSH Key Generation
Loaded: loaded (/lib/systemd/system/sshdgenkeys.service; static)
Active: inactive (dead)
root@localhost:~# systemctl start sshdgenkeys.service
root@localhost:~# systemctl status sshdgenkeys.service
* sshdgenkeys.service - OpenSSH Key Generation
Loaded: loaded (/lib/systemd/system/sshdgenkeys.service; static)
Active: active (exited) since Wed 2024-04-17 13:47:27 UTC; 2s ago
Process: 640 ExecStart=/usr/libexec/openssh/sshd_check_keys (code=exited, status=0/SUCCESS)
Main PID: 640 (code=exited, status=0/SUCCESS)
Apr 17 13:47:24 localhost systemd[1]: Starting OpenSSH Key Generation...
Apr 17 13:47:26 localhost sshd_check_keys[646]: unknown option -- G
Apr 17 13:47:26 localhost sshd_check_keys[646]: OpenSSH_8.9p1, OpenSSL 3.0.8 7 Feb 2023
Apr 17 13:47:26 localhost sshd_check_keys[646]: usage: sshd [-46DdeiqTt] [-C connection_spec] [-c host_cert_file]
Apr 17 13:47:26 localhost sshd_check_keys[646]:             [-E log_file] [-f config_file] [-g login_grace_time]
Apr 17 13:47:26 localhost sshd_check_keys[646]:             [-h host_key_file] [-o option] [-p port] [-u len]
Apr 17 13:47:27 localhost systemd[1]: Finished OpenSSH Key Generation.

root@localhost:~#

The output shows that the service is loaded but inactive. When I start it manually, it becomes active, but I encounter a strange error: "unknown option -- G." It seems like the version of sshd_check_keys script being used is newer and expects "sshd -G," whereas my .bbappend file is for version 8.9p1.

I'm not sure why this discrepancy is occurring. Any thoughts?

Cheers,
Nitesh

author
#5 lore raw

Re: [yocto] Issue with Installing openssh Package #systemd #yocto #kirkstone

Peter,

So I did little clean up and fixed the error: "unknown option -- G.", so that is taken care.

Now the only issue is getting this service "sshdgenkeys.service" enabled by default.

Just to recap, I have "openssh-sshd" disable by default and "openssh-sshdgenkeys" enable:

SYSTEMD_AUTO_ENABLE:${PN}-sshd = "disable"
SYSTEMD_AUTO_ENABLE:${PN}-sshdgenkeys = "enable"

But it looks like it is getting override and disable.

Thoughts?