Skip to content

debos: install and enable openssh-server for SSH access#348

Open
vemana1niranjan wants to merge 1 commit intoqualcomm-linux:mainfrom
vemana1niranjan:feature/add_packages_openssh_server
Open

debos: install and enable openssh-server for SSH access#348
vemana1niranjan wants to merge 1 commit intoqualcomm-linux:mainfrom
vemana1niranjan:feature/add_packages_openssh_server

Conversation

@vemana1niranjan
Copy link
Copy Markdown
Contributor

Install openssh-server and enable the ssh service during image build so SSH access is available immediately after first boot.

@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch 2 times, most recently from 3b83f17 to 523ff2c Compare April 3, 2026 05:53
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

Test jobs for commit 1b5bee5

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

Test jobs for commit 3b83f17

Copy link
Copy Markdown
Contributor

@gagath gagath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, this avoids using the serial port to install a ssh server. This will also be useful when we move our qemu tests from expect to something a bit more robust.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

Test Results

 2 files  ±0   6 suites  ±0   3m 42s ⏱️ ±0s
20 tests ±0  20 ✅ ±0  0 💤 ±0  0 ❌ ±0 
64 runs  ±0  64 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit c03842e. ± Comparison against base commit 874cb4c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

Test jobs for commit 523ff2c

@lool
Copy link
Copy Markdown
Contributor

lool commented Apr 3, 2026

While I would like to see SSH supported and that might be useful for testing as well, this doesn't combine well with our default password. Could we compile what our other images do by default?

If we had something like cloud-init, we could install but disable SSH and turn it on through c-i. Or we could leave it on but have no password to login, and let people set that up through c-i.

It would also be nice to have a simple check to ensure we don't include SSH keys in the resulting images.

@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from 523ff2c to e0b53da Compare April 6, 2026 05:25
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

Test jobs for commit e0b53da

@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from e0b53da to 72ef751 Compare April 6, 2026 06:49
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

Test jobs for commit 72ef751

@vemana1niranjan
Copy link
Copy Markdown
Contributor Author

While I would like to see SSH supported and that might be useful for testing as well, this doesn't combine well with our default password. Could we compile what our other images do by default?

If we had something like cloud-init, we could install but disable SSH and turn it on through c-i. Or we could leave it on but have no password to login, and let people set that up through c-i.

It would also be nice to have a simple check to ensure we don't include SSH keys in the resulting images.

recent update to PR making this .is this good

Copy link
Copy Markdown
Contributor

@lool lool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left various proposed improvements; coud you also add a commit message and fixed your signed-off-by to use your full name?

Comment thread debos-recipes/qualcomm-linux-debian-rootfs.yaml Outdated
Comment thread debos-recipes/qualcomm-linux-debian-rootfs.yaml Outdated
Comment thread debos-recipes/qualcomm-linux-debian-rootfs.yaml Outdated
Comment thread debos-recipes/qualcomm-linux-debian-rootfs.yaml Outdated
@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from 72ef751 to 457a580 Compare April 8, 2026 09:31
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

Test jobs for commit 457a580

@vemana1niranjan vemana1niranjan requested a review from lool April 9, 2026 05:10
@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from 457a580 to 4919cb4 Compare April 9, 2026 05:23
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Test jobs for commit 4919cb4

# convenience networking commands (arp, ifconfig, route etc.)
- net-tools
- openssh-client
# A SSH server is installed but disabled by default; enable with sudo systemctl enable ssh.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a comment only when the package name doesn't make it obvious; here, an insightful comment would be "disabled by default after install"

Could you also cover that in a README update? "A SSH server is installed but disabled by default; enable with `sudo systemctl enable "

Copy link
Copy Markdown
Contributor

@lool lool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why my review wasn't fully sent

@github-actions
Copy link
Copy Markdown

Test jobs for commit 36db5d4

@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from 36db5d4 to 6a31c3a Compare April 17, 2026 06:33
@github-actions
Copy link
Copy Markdown

Test jobs for commit c44e994

# convenience networking commands (arp, ifconfig, route etc.)
- net-tools
- openssh-client
# OPENSSH is installed but disabled by default.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a weird way to write that name; either OpenSSH or openssh

or just write "disabled by default" since that's the only interesting part

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to "disabled by default"

command: |
set -eux
rm -f /etc/ssh/ssh_host_*
rm -rf /root/.ssh /home/*/.ssh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the root/.ssh part, there is no chance this will be generated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed root/.ssh part kept the /home/*/.ssh

- wget

- action: run
description: Sanitize SSH keys
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action is about disabling SSH by default; update the description to match

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed description to "Disable ssh by default and sanitize ssh keys"

chroot: true
command: |
set -eux
rm -f /etc/ssh/ssh_host_*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to check if the keys are present and fail if so; we don't want a silent removal, we want to escalate the issue if these keys were somehow generated.

Also, move this logic to AFTER disabling and potentially stopping the service.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made change logic starts after disabling if found printing error mesg in rootfs generation part and forcely exiting rootfs generation

set -eux
rm -f /etc/ssh/ssh_host_*
rm -rf /root/.ssh /home/*/.ssh
systemctl disable ssh 2>/dev/null || true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to pass --now as well as that seems stricter.

Don't ignore failure, or explain why we want to run it if it's expected to fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to add --now but
flag fails because systemd is not running in the chroot build environment

Comment thread README.md Outdated
`qcs9100-ride-r3`, `qrb2210-rb1`.

Note: Boards whose required device tree (.dtb) is not present in `dtbs.tar.gz` are automatically skipped during flash asset generation.
Note: "A SSH server is installed but disabled by default; enable with sudo systemctl enable ssh".
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong place to add this change; look at the whole README and find the place which makes the most sense. I would place it near the login instructions since this is a note about usage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding at login instructions

@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from c44e994 to b66dbf7 Compare April 22, 2026 10:10
@github-actions
Copy link
Copy Markdown

Test jobs for commit b66dbf7

@github-actions
Copy link
Copy Markdown

Test jobs for commit 6067689

@vemana1niranjan vemana1niranjan requested a review from lool April 27, 2026 09:11
@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from 6067689 to fd8d793 Compare April 28, 2026 05:47
@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from fd8d793 to c03842e Compare April 28, 2026 05:58
@github-actions
Copy link
Copy Markdown

Test jobs for commit fd8d793

@github-actions
Copy link
Copy Markdown

Test jobs for commit c03842e

Copy link
Copy Markdown
Contributor

@lool lool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, some shell syntax issues

Please update the commit message to reflect the latest changes

echo "ERROR: SSH host keys were unexpectedly generated" >&2
exit 1
fi
rm -rf /home/*/.ssh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this rm, no chance of being created during build (otherwise it should be a check as above)

command: |
set -eux
systemctl disable ssh
if [ -f /etc/ssh/ssh_host_* ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this expands to multiple files, the test command will be incorrect

chroot: true
command: |
set -eux
systemctl disable ssh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add --now

@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from c03842e to 728ad14 Compare April 28, 2026 11:05
chroot: true
command: |
set -eux
systemctl disable ssh --now
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might work, but it's an unusual position for flags; disable --now ssh instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even this "systemctl disable --now ssh" local build failing with this error message
msg : --now cannot be used when systemd is not running.

There is interesting observation below in trixie build fails with same error and in forky build this error was not found

so shall i remove --now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be conflicting situations in your attempts; you report commands fail because systemd is not running (and indeed, then --now makes no sense, I can see why systemd would reject it, and we should drop it), but some recent failures also show that --now is accepted, and that the SSH keys were generated, which suggest that we're in the opposite situation:

2026/04/29 10:53:34 ==== Disable ssh by default and sanitize ssh keys ====
2026/04/29 10:53:34 set -eux... | + systemctl disable --now ssh
2026/04/29 10:53:34 set -eux... | Removed '/etc/systemd/system/multi-user.target.wants/ssh.service'.
2026/04/29 10:53:34 set -eux... | Removed '/etc/systemd/system/sshd.service'.
2026/04/29 10:53:34 set -eux... | + [ -f /etc/ssh/ssh_host_ecdsa_key ]
2026/04/29 10:53:34 set -eux... | + basename /etc/ssh/ssh_host_ecdsa_key
2026/04/29 10:53:34 set -eux... | + echo ERROR: SSH host key (ssh_host_ecdsa_key) was unexpectedly generated

I'm not clear on when/how debos is preventing systemd from running, I would expect most image generation tools to work in chroots and disable system services entirely though some kind of policy files or replacing the binaries.

It's risky for us to run daemons such as SSH during image generation because we might end up with keys or ids that were generated once and are distributed everywhere, when they are supposed to be private or unique and generated on the first boot after flashing.

command: |
set -eux
systemctl disable ssh --now
if [ -f /etc/ssh/ssh_host_rsa_key ] || [ -f /etc/ssh/ssh_host_ecdsa_key ] || [ -f /etc/ssh/ssh_host_ed25519_key ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not robust against addition of key types in the future...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to add a generic loop over ssh_host_*_key

but observations are host keys are always copied in initial ssh-server package during debos install
so, removing them forcefully might be needed with (rm)

else build will always fail
is there any alternative way?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to add a generic loop over ssh_host_*_key

but observations are host keys are always copied in initial ssh-server package during debos install so, removing them forcefully might be needed with (rm)

else build will always fail is there any alternative way?

this requires researching why in debos openssh is being started and generates keys; I believe it shouldn't

Add the openssh server to support external ssh connections, disable it by
default, and add a sanity check to error out if ssh host keys are generated
during build or install, preventing unintended remote access and shipping
pre-generated ssh identities.

Signed-off-by: Niranjan Vemana <nvemana@qti.qualcomm.com>
@vemana1niranjan vemana1niranjan force-pushed the feature/add_packages_openssh_server branch from 728ad14 to 7e9bb29 Compare April 29, 2026 10:47
set -eux
systemctl disable --now ssh
for keyfile in /etc/ssh/ssh_host_*_key; do
if [ -f ${keyfile} ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shell snippet is slightly broken, on some shells it will result in an error if the files are missing; on bash, it will expand to run the loop once with keyfile=/etc/ssh/ssh_host_*_key. Then the [ -f test call will try the same missing expansion again. It's very confusion and an unorthodox way of testing for the presence of a pattern of files.

Instead, I'd recommend using "find".

Add quotes around the keyfile use, it shouldn't be wildcard-expanded again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants