Ubuntu Core: Create / Set a user?

I’ve read core/docs/system-user and System user - Ubuntu Core docs - Ubuntu Community Hub

I am using Core22.

its still not clear to me how you can create a user (or is it even possible?)

At the moment I am iterating over imaging an SD card and putting it in a raspberry pi (testing my own snap, and configs etc)

I am constantly putting in my ubuntu-one email when console-conf kicks in after each fresh image. The docs state " Some systems, however, suppress console-conf and its user creation." I am unclear what that means? How is it suppressed? Does ‘some systems’ mean hardware (no way of having a keyboard)?

I’ve read about asserting a system-user, and using a USB key on boot, thinks makes me think user creation is not possible.

I have 2 questions.

1 - As I am developing (dangerous / devmode), is there a way of asserting my ubuntu-one user 'by id, pub key, or email) so I don’t keep having to enter it? Can a key be added to ssh ‘authorized_keys’ via a gadget snap and set it that way (I don’t thing it uc works that way)?

2 - My goal is to eventually share my custom core22 image with my snap asserted, can I have a user setup with that? I obv also do not want console-conf kicking in either, i know core24 allows for "presence" ? on console-conf but can’t see anything for core22. This user is not essential, it will be a nice to have, its purely there for debugging over ssh if I have any trouble in the future, but removing console-conf is.

Any help (links / github) are very appreciated.

Cheers

I believe, in a Gadet Snap I can do

defaults:
  system:
    service.console-conf.disable: true

still looking how I can create a preloaded user…

Hi @Eggplant5956

I’m not sure there is any way to create a preloaded user, as such. However, there are ways to automatically add users when the system installs and snaps are seeded, although your options may be limited a bit by your usage [ like, if you have a Brand Store this is probably easier ? although happy to be corrected on that ]

For instance, you can have a dedicate snap which contains the system-user assertion, and has a service that adds the assertion and sets up the user, talking to the snapd api via the snapd socket. In order to do that the service/app in this snap needs the snapd-control interface plug connected, which is much easier to arrange if you have a Brand Store.

If you don’t have a Brand Store, but you still have a custom gadget snap, you may be able to use that to connect the required interface plug. Details here.

There could be other approaches. There is kind of rudimentary support for cloud-init, it only gets run on first boot, then never again [ it get’s disabled ]. You might be able to use that to setup a user. Again, it requires a custom gadget snap. The cloud-init support in Ubuntu Core isn’t well documented [ unless I’ve missed something ].

I have some vague notes on cloud-init with core, posting in case it helps:

cloud.conf example [ include whatever you want, but I think datasource_list: [NoCloud] part is required ]

#cloud-config
datasource_list: [NoCloud]
users:
  - name: example-user
    shell: /bin/bash
    ssh_authorized_keys:
      - <your_public_key_here>

Add a part to your gadget to include the cloud.conf file, something like this if the file is in the root of you gadget snap repo:

  cloud-init:
    plugin: dump
    source: .
    stage:
      - cloud.conf

Hope that helps.

Cheers, Just

Please do not use cloud-init in any production systems, it is not designed for UbuntuCore at all… (It is fine to use it as a hack for i.e. test systems to run automated self tests and the like and even for adding users in that context)