The users every system gets

root/root, ubuntu/ubuntu for users

The common cloud-init template gives every cloud system root with the password root and a user named after the distribution's group, with the same word as password and passwordless sudo; the .run script reports them with --query, from the system's kind rather than from the user-data.

On the map: first boot

▶ Watch this deck — 7 scenes, ~5 min

Worth seeing first

01 Who do you log in as?

LOGGING IN ubuntu-24-04 login: _ Password: the cloud image: no passwords it waits for a cloud to hand it an SSH key image-garden's user-data creates the accounts itself root password root ubuntu password ubuntu each account · asking the .run script · what fixed passwords mean
The console of ubuntu-cloud-24.04 asks for a login; the cloud image has no password and waits for an SSH key from a cloud; image-garden creates two accounts in the user-data instead: root with password root and ubuntu with password ubuntu

Every cloud system gets root with password root and a user named after the distribution, such as ubuntu with password ubuntu.

You've built ubuntu-cloud-24.04.x86_64, started its .run script, and the console asks you to log in. With what? A cloud image comes with no password for anyone: it expects the cloud to hand it an SSH key. Your machine hands it none, so image-garden creates the accounts itself, in the user-data. Every cloud system gets two of them. One is root, with the password root. The other is named after the distribution, here ubuntu, with the same word as its password. This deck looks at each one, at how to ask a system which accounts it has, and at what fixed passwords mean.

Details and sources

Details

  • The common user-data template's users: list: root with plain_text_passwd: root, and $2, the group's name, with plain_text_passwd: $2 (010-qemu.mk:200-211).
  • The README's security notice: "Fixed passwords: root/root for root account, distribution name (e.g., ubuntu/ubuntu) for user account" (README.md:25-31).
  • The login prompt shows the host name the user-data sets, ubuntu-24-04 for this system (010-qemu.mk:196).
  • Derived, not from the tree: distribution cloud images ship without a usable password and expect a cloud's metadata to supply SSH keys.
  • Ubuntu Core has its own template and only the ubuntu user: see Ubuntu Core images.

02 root, with the password root

ROOT users: - name: root plain_text_passwd: root lock_passwd: false unlocked: the password works shell: /bin/bash why: tests often need root, and a known password needs no keys ubuntu-24-04 login: root Password: root root@ubuntu-24-04:~# on the console: straight away root over SSH with a password: two more changes, in the SSH deck
The root entry of the user-data: name root, plain_text_passwd root, lock_passwd false, shell /bin/bash; root gets a password so that tests can use it without keys; on the console you log in as root with password root; SSH logins as root need two more changes

root: plain_text_passwd: root, lock_passwd: false, shell /bin/bash. SSH logins as root need the changes in the SSH deck.

The first account is root. The user-data sets its password to root, in plain text, and unlocks the account, so the password really works. Its shell is bash. Why give root a password at all? Tests often need root, and a known password means anything can log in as root without setting up keys first. That covers the console, which works straight away: type root, then root again. Logging in as root over SSH with a password takes two more changes on the SSH side, and those have their own deck.

Details and sources

Details

  • The root entry: name: root, plain_text_passwd: root, lock_passwd: false, shell: /bin/bash (010-qemu.mk:201-204).
  • SSH as root needs PermitRootLogin yes and password authentication, both set elsewhere in the same user-data (010-qemu.mk:197, 010-qemu.mk:214-220); see SSH logins and apt sources.
  • Derived, from cloud-init's behaviour: lock_passwd: false leaves the account's password usable; cloud-init locks it by default.
  • The shell prompt on the slide is illustrative.

03 A user named after the distribution

THE DISTRIBUTION USER - name: ubuntu the group, first in the system name: ubuntu debian fedora alpine and so on plain_text_passwd: ubuntu groups: users gecos: ubuntu User lock_passwd: false shell: /bin/bash sudo: ["ALL=(ALL) NOPASSWD:ALL"] sudo for everything, no prompt ubuntu-cloud-24.04.x86_64 ubuntu / ubuntu debian-cloud-13.x86_64 debian / debian
The second user entry: name ubuntu, groups users, gecos ubuntu User, plain_text_passwd ubuntu, sudo ALL=(ALL) NOPASSWD:ALL, lock_passwd false, shell /bin/bash; the name is the distribution's group, such as ubuntu, debian, fedora or alpine; Ubuntu 24.04 gets ubuntu/ubuntu and Debian 13 debian/debian

The second user is the group's name with the same password, in group users, with sudo: ["ALL=(ALL) NOPASSWD:ALL"] and bash.

The second account takes its name from the group, the first part of the system's name: ubuntu, debian, fedora, alpine, and so on. Its password is the same word. It's a member of the users group, its full name reads ubuntu User, and its shell is bash. It also gets sudo for everything, without a password. So once you're in as ubuntu, sudo works without a prompt, which is what a script needs that runs as an ordinary user and switches to root now and then. On Ubuntu 24.04 that's ubuntu and ubuntu; on Debian 13 it's debian and debian.

Details and sources

Details

  • The second entry: name: $2, groups: users, gecos: $2 User, plain_text_passwd: $2, sudo: ["ALL=(ALL) NOPASSWD:ALL"], lock_passwd: false, shell: /bin/bash (010-qemu.mk:205-211).
  • $2 is the group, passed twice by the user-data rule: once as the group and once as the user name (rulegen.py:467). The group is the Group= of the file's [META] section, such as Group=ubuntu (ubuntu.ini:4-6) or Group=debian (debian.ini:4-6).
  • The groups in data/*.ini: almalinux, alpine, amazonlinux, archlinux, centos, debian, fedora, gentoo, opencloudos, opensuse, oracle, rocky, ubuntu. Each is also the user name and its password.
  • Named instances use the base system's group too (020-instances.mk:75).

04 Ask the .run script

ASK THE SCRIPT $ ./ubuntu-cloud-24.04.x86_64.run --query system.users.0.username=root system.users.0.password=root system.users.1.username=ubuntu system.users.1.password=ubuntu $ ./ubuntu-core-24.x86_64.run --query vm.memory_mb=2048 system.users.0.username=ubuntu system.users.0.password=ubuntu Ubuntu Core: no root login snapcraft-vm · rockcraft-vm · charmcraft-vm ssh as user 0 with its password, sudo -H unless that user is root vm.memory_mb=2048 allocate: vm.memory_mb against the host's free memory
Running ubuntu-cloud-24.04.x86_64.run --query prints vm.memory_mb=2048 and users 0 and 1: root/root and ubuntu/ubuntu; ubuntu-core-24.x86_64.run --query lists only ubuntu/ubuntu; snapcraft-vm, rockcraft-vm and charmcraft-vm log in as user 0 and add sudo unless it is root; allocate compares vm.memory_mb with the host's free memory

./ubuntu-cloud-24.04.x86_64.run --query prints system.users.0 root/root and system.users.1 ubuntu/ubuntu. Ubuntu Core lists only ubuntu.

Tools shouldn't guess these names. Every .run script answers --query with a few properties of its system, and among them are the users, numbered from zero. For our system that's root with root, then ubuntu with ubuntu. Ubuntu Core is the exception: its script names only ubuntu, because root can't log in there. The CI components that build snaps, rocks and charms rely on this. After allocate, they ask the script, take user zero and its password, and add sudo only when that user isn't root. allocate itself asks the same script for the memory size, before it starts the machine.

Details and sources

Details

  • The --query preamble of every .run script prints vm.memory_mb, then the users: for root distro, system.users.0 is root/root and system.users.1 the group's name twice; for only:ubuntu, system.users.0 is ubuntu/ubuntu (010-qemu.mk:57-92).
  • Systems from data/*.ini use root distro (query_users, rulegen.py:127), and so do their named instances (020-instances.mk:89); the Ubuntu Core launchers pass only:ubuntu (050-ubuntu-core.mk:23-26).
  • The QUERY file documents the format and both examples (QUERY:31-69).
  • snapcraft-vm reads system.users.0.username and .password from the query, logs in with sshpass, and sets sudo='sudo -H' unless the user is root (snapcraft-vm:374-381); rockcraft-vm and charmcraft-vm do the same.
  • allocate runs memory_check on the .run script once make has made it, before it starts the machine (image-garden:1066-1068); memory_check reads vm.memory_mb and compares it with MemAvailable (image-garden:712-730).
  • The memory value follows QEMU_MEM_OPTION when it is set; 2048 is the default (010-qemu.mk:9).

05 Change the users, and the query doesn't know

A TRAP - name: root plain_text_passwd: s3cret your template the machine root's password: s3cret $ ./….run --query system.users.0.password=root the template is never read for this make writes the .run script from the kind of system: root distro a tool that trusts the query root / root: the login fails keep root and the distribution user, or tell your tools yourself
A project template sets root's password to s3cret and the machine gets it; the .run script's --query still says root, because make wrote the answers from the kind of system and never reads the template; a tool that trusts the query fails to log in; keep the usual accounts or tell your tools the new passwords

The --query answers are fixed when the .run script is made, from the kind of system. A template that changes passwords does not change them.

Here's a trap. Say your project's template changes the accounts, with another password for root. The machine gets the new password, but --query still says root and root. The run script never reads the user-data. Its answers are written into it when make generates it, from the kind of system, not from your template. So a tool that trusts the query tries the old password and can't log in. If you change the users, keep root and the distribution user with their usual passwords, or give your tools the new ones yourself.

Details and sources

Details

  • The --query answers are echo lines that make writes into the .run script; the users come from the third argument of EMIT_QEMU_RUN_SCRIPT_QUERY_PREAMBLE, root distro or only:ubuntu, and the group (010-qemu.mk:57-92).
  • The .run rule passes {img.query_users} and the group (rulegen.py:594-599); a named instance passes root distro and its base system's group (020-instances.mk:87-89). The .run rule does not depend on the user-data.
  • Derived: nothing in the .run script or its rule reads the user-data, so a template that changes the users leaves --query as it was.
  • The password s3cret is an example.

06 Fixed passwords, on purpose

INSECURE ON PURPOSE README security notice fixed passwords SSH password logins for testing only hostfwd=tcp:127.0.0.1:PORT-:22 allocate: from this machine only your network cannot reach that port the .run script no port forwarded unless you add one don't: forward its SSH to an address others can reach don't: keep anything in it a stranger shouldn't read
The README's security notice lists fixed passwords, SSH password logins and test-only images; allocate forwards SSH from 127.0.0.1 only, so other machines cannot reach it; the .run script forwards no ports by default; do not expose a garden VM's SSH or keep secrets in it

Fixed passwords are a deliberate trade for testing. allocate forwards 127.0.0.1:PORT only; the .run script forwards nothing by default.

All of this is insecure on purpose, and the README says so in its security notice: fixed passwords, password logins over SSH, images for testing only. That's fine for what they're for. allocate forwards SSH from 127.0.0.1 only, so another machine on your network can't reach that port. The plain .run script forwards no ports at all unless you add one. So keep it that way. Don't forward a garden VM's SSH to an address others can reach, and don't put anything in it that you'd mind a stranger reading.

Details and sources

Details

  • The README's security notice: "These images are designed for testing and explicitly compromise security for convenience", with fixed passwords, SSH password authentication enabled by default, and "NOT suitable for production use" (README.md:25-39).
  • allocate sets QEMU_NETDEV_USER_EXTRA=",hostfwd=tcp:127.0.0.1:$PORT-:22" (image-garden:1105-1107).
  • The .run script's network is -netdev user,id=netdev0 plus QEMU_NETDEV_USER_EXTRA when you set it (010-qemu-x86_64.mk:8-11), so it forwards no host port by default.
  • The same notice says that guests' apt sources are switched from HTTPS to HTTP so that pkgproxy can cache packages, while images and their checksum lists are downloaded over HTTPS and checked (README.md:32-35); see SSH logins and apt sources.

07 Where to go from here

ROADS The users SSH and apt password and root logins allocate a port to log in on The spread backend user and password for spread Insecure on purpose where to run garden VMs Picking a template for other users
Roads from this deck: SSH logins and apt sources, allocate, the spread adhoc backend, test images insecure on purpose, and how a user-data template is chosen

Next: SSH logins, allocate, spread's backend, safety, and templates.

Two accounts, root and one named after the distribution, with passwords anyone can guess, and the run script tells tools what they are. The SSH deck shows how password and root logins are opened up. allocate is how you get a port to log in on, and the spread backend is where the user name and password are written down for spread. The safety deck says what all this means for where you run garden VMs. And if you want other users, start with how a template is chosen.

Details and sources

Read more

Basis of the statements on this page

Read in mk/010-qemu.mk, mk/050-ubuntu-core.mk, rulegen.py, data/*.ini and QUERY of image-garden at the commit this map describes, and in bin/snapcraft-vm of snapcraft-gitlab-ci ("code"). The user names per group are worked out from the template ("derived"). One run: the --query of a named instance, made with image-garden make from an export of that commit.

Accounts per system

SystemsUsersPasswordssudo
every system from data/*.ini, and their named instancesroot, and the group's nameroot, and the group's namethe group user: ALL=(ALL) NOPASSWD:ALL
Ubuntu Coreubuntuubuntusee Ubuntu Core images

The common template's users: list (010-qemu.mk:200-211). A project template that starts from $(CLOUD_INIT_USER_DATA_TEMPLATE) keeps both accounts.

User names by group

Group ([META] Group=)User and passwordExample system
almalinuxalmalinuxalmalinux-cloud-9.x86_64
alpinealpinealpine-cloud-3.x86_64
amazonlinuxamazonlinuxamazonlinux-cloud-2023.x86_64
archlinuxarchlinuxarchlinux-cloud.x86_64
centoscentoscentos-cloud-10.x86_64
debiandebiandebian-cloud-13.x86_64
fedorafedorafedora-cloud-42.x86_64
gentoogentoogentoo-cloud.x86_64
opencloudosopencloudosopencloudos-cloud-9.x86_64
opensuseopensuseopensuse-cloud-16.0.x86_64
oracleoracleoracle-cloud-9.x86_64
rockyrockyrocky-cloud-10.x86_64
ubuntuubuntuubuntu-cloud-24.04.x86_64

--query output

$ ./ubuntu-cloud-24.04.x86_64.run --query
vm.memory_mb=2048
system.users.0.username=root
system.users.0.password=root
system.users.1.username=ubuntu
system.users.1.password=ubuntu

From the QUERY file's example (QUERY:55-69) and the preamble that prints it (010-qemu.mk:57-92). The users are fixed when make writes the .run script; only vm.memory_mb follows the environment (QEMU_MEM_OPTION). A named instance's script prints its base system's users the same way: run for this map, ./amazonlinux-cloud-2@web.x86_64.run --query printed root/root and amazonlinux/amazonlinux.

Roads from here

START HERE

UBUNTU CORE · all snaps

RUNTIME · make rules and the CLI

SPREAD · tests

FIRST BOOT · cloud-init changes