Skip to content

[BUG]: Using an SSH key with a : in the comment causes cloud-init to crash #1544

@michiel-de-muynck

Description

@michiel-de-muynck

What happened?

Summary:

Using the following public key in the Raspberry Pi imager causes cloud-init to crash, resulting in a Raspberry Pi that doesn't accept the SSH key:

sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIOmUf+yf1TM4RXLJhOCyIiHZBT08PQMQsWkID886DMtkAAAABHNzaDo= ssh:

More details:

I did some investigation into what I believe causes this:

  • Note that the public key ends with the comment "ssh:". I didn't choose this myself, I ended up with this by importing it from my yubikey with ssh-keygen -K.
  • This causes /var/lib/cloud/instances/rpi-imager-1773264665707/cloud-config.txt to end up with the weird yaml
users:
-   ssh_authorized_keys:
    -   ? sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIOmUf+yf1TM4RXLJhOCyIiHZBT08PQMQsWkID886DMtkAAAABHNzaDo=
            ssh
        : null
    sudo: ALL=(ALL) NOPASSWD:ALL

Version

2.0.6 (Default)

What host operating system were you using?

Windows

Host OS Version

11

Selected OS

Raspberry Pi OS Trixie 64-bit

Which Raspberry Pi Device are you using?

Raspberry Pi 5, 500, and Compute Modules 5

What kind of storage device are you using?

USB SSD

OS Customisation

  • Yes, I was using OS Customisation when the bug occurred.

Relevant log output

2025-12-04 14:50:58,494 - log_util.py[DEBUG]: Running module users_groups (<module 'cloudinit.config.cc_users_groups' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py'>) failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/config/modules.py", line 297, in _run_modules
    ran, _r = cc.run(
              ~~~~~~^
        run_name, mod.handle, func_args, freq=freq
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 71, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 156, in run
    results = functor(**args)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py", line 80, in handle
    cloud.distro.create_user(user, **config)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 1003, in create_user
    keys = set(keys) or []
           ~~~^^^^^^
TypeError: unhashable type: 'dict'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions