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
- From a system's name to a running VM — the provisioning boot that creates the accounts
01 Who do you log in as?
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:rootwithplain_text_passwd: root, and$2, the group's name, withplain_text_passwd: $2(010-qemu.mk:200-211). - The README's security notice: "Fixed passwords:
root/rootfor 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-04for 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
ubuntuuser: see Ubuntu Core images.
Read more
02 root, with the password root
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 yesand 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: falseleaves the account's password usable; cloud-init locks it by default. - The shell prompt on the slide is illustrative.
Read more
03 A user named after the distribution
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). $2is 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 theGroup=of the file's[META]section, such asGroup=ubuntu(ubuntu.ini:4-6) orGroup=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).
Read more
04 Ask the .run script
./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
--querypreamble of every.runscript printsvm.memory_mb, then the users: forroot distro,system.users.0is root/root andsystem.users.1the group's name twice; foronly:ubuntu,system.users.0is ubuntu/ubuntu (010-qemu.mk:57-92). - Systems from
data/*.iniuseroot distro(query_users, rulegen.py:127), and so do their named instances (020-instances.mk:89); the Ubuntu Core launchers passonly:ubuntu(050-ubuntu-core.mk:23-26). - The QUERY file documents the format and both examples (QUERY:31-69).
snapcraft-vmreadssystem.users.0.usernameand.passwordfrom the query, logs in withsshpass, and setssudo='sudo -H'unless the user is root (snapcraft-vm:374-381);rockcraft-vmandcharmcraft-vmdo the same.allocaterunsmemory_checkon the.runscript once make has made it, before it starts the machine (image-garden:1066-1068);memory_checkreadsvm.memory_mband compares it withMemAvailable(image-garden:712-730).- The memory value follows
QEMU_MEM_OPTIONwhen it is set; 2048 is the default (010-qemu.mk:9).
05 Change the users, and the query doesn't know
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
--queryanswers areecholines that make writes into the.runscript; the users come from the third argument ofEMIT_QEMU_RUN_SCRIPT_QUERY_PREAMBLE,root distrooronly:ubuntu, and the group (010-qemu.mk:57-92). - The
.runrule passes{img.query_users}and the group (rulegen.py:594-599); a named instance passesroot distroand its base system's group (020-instances.mk:87-89). The.runrule does not depend on the user-data. - Derived: nothing in the
.runscript or its rule reads the user-data, so a template that changes the users leaves--queryas it was. - The password
s3cretis an example.
Read more
06 Fixed passwords, on purpose
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).
allocatesetsQEMU_NETDEV_USER_EXTRA=",hostfwd=tcp:127.0.0.1:$PORT-:22"(image-garden:1105-1107).- The
.runscript's network is-netdev user,id=netdev0plusQEMU_NETDEV_USER_EXTRAwhen 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.
Read more
07 Where to go from here
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
| Systems | Users | Passwords | sudo |
|---|---|---|---|
every system from data/*.ini, and their named instances | root, and the group's name | root, and the group's name | the group user: ALL=(ALL) NOPASSWD:ALL |
| Ubuntu Core | ubuntu | ubuntu | see 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 password | Example system |
|---|---|---|
| almalinux | almalinux | almalinux-cloud-9.x86_64 |
| alpine | alpine | alpine-cloud-3.x86_64 |
| amazonlinux | amazonlinux | amazonlinux-cloud-2023.x86_64 |
| archlinux | archlinux | archlinux-cloud.x86_64 |
| centos | centos | centos-cloud-10.x86_64 |
| debian | debian | debian-cloud-13.x86_64 |
| fedora | fedora | fedora-cloud-42.x86_64 |
| gentoo | gentoo | gentoo-cloud.x86_64 |
| opencloudos | opencloudos | opencloudos-cloud-9.x86_64 |
| opensuse | opensuse | opensuse-cloud-16.0.x86_64 |
| oracle | oracle | oracle-cloud-9.x86_64 |
| rocky | rocky | rocky-cloud-10.x86_64 |
| ubuntu | ubuntu | ubuntu-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
- Test images, insecure on purpose — what fixed passwords mean for where you run garden VMs
UBUNTU CORE · all snaps
- Ubuntu Core images — Ubuntu Core, where only ubuntu can log in
RUNTIME · make rules and the CLI
- image-garden allocate — how allocate gives you a port to log in on
SPREAD · tests
- The adhoc backend: allocate and discard — how spread is told the user name and password
FIRST BOOT · cloud-init changes
- SSH logins and apt sources — how SSH is opened up for these passwords and for root
- How a user-data template is chosen — how to change the users with a template of your own