Disabling SSH by default (but keeping the service)


Josef Holzmayr
 

Hi Maik,

this is a number of things being mixed up.
1) a recipe cannot affect another recipe. the image is a recipe, sshd is a recipe. so you either can set this in a bbappend to thesshd recipe, or in a config file (distro, machine, local) - but not in the image.
2) the override separator is : these days (since dunfell), not _, and you are targetting a specific recipe. so in a config file, it would be SYSTEMD_AUTO_ENABLE:pn-openssh-sshd
[3] 7.6p1 suggests that you are on some release made in 2017, or comparable, and the first thing you should do is upgrade, or otherwise you will be shipping outdated and vulnerable software right from day 1.

Greetz

On Thu, Oct 13, 2022 at 3:34 PM Leon Woestenberg <leon@...> wrote:
Hello Maik,

On Thu, Oct 13, 2022 at 3:17 PM Maik Vermeulen
<maik.vermeulen@...> wrote:
> We tried two things to disable SSH by default in our image recipe:
> However, both methods don't seem to work.

Hmm, something else might override it elsewhere? I don't know.

Seems like a similar question came up in stackoverflow, where some
potential solutions are given that you might want to give a try:

https://stackoverflow.com/questions/50651371/disable-a-standard-systemd-service-in-yocto-build

Regards,

Leon.




Leon Woestenberg
 

Hello Maik,

On Thu, Oct 13, 2022 at 3:17 PM Maik Vermeulen
<maik.vermeulen@...> wrote:
We tried two things to disable SSH by default in our image recipe:
However, both methods don't seem to work.
Hmm, something else might override it elsewhere? I don't know.

Seems like a similar question came up in stackoverflow, where some
potential solutions are given that you might want to give a try:

https://stackoverflow.com/questions/50651371/disable-a-standard-systemd-service-in-yocto-build

Regards,

Leon.


Maik Vermeulen
 

Hi,

We tried two things to disable SSH by default in our image recipe:
inherit systemd
SYSTEMD_AUTO_ENABLE_openssh-sshd = "disable"

pkg_postinst_ontarget_openssh () {
    systemctl disable --now sshd.socket
}

However, both methods don't seem to work. We can still SSH to the device.
Furthermore, this is the unit list:
sshdgenkeys.service            loaded active exited       OpenSSH Key Generation
system-sshd.slice                 loaded active active        system-sshd.slice
sshd.socket                          loaded active listening    sshd.socket

We are on openssh_7.6p1.

Any ideas why this is happening?

Kind regards,

Maik Vermeulen

Embedded Software Engineer — Lightyear






Automotive Campus 70 —5708 JZ Helmond, the Netherlands

This email may contain information which is privileged and/or confidential. If you received this e-mail in error, please notify us immediately by e-mail and delete the email without copying or disclosing its contents to any other person. Lightyear is a trade name of Atlas Technologies B.V. and is registered at the Dutch Chamber of Commerce under number 67264298.