I'm netboot installing Ubuntu focal and I have all the basic stuff working without issue. I use this template as the user-data yaml file and it makes the user, sets the password, and imports whatever ssh key I specify:
#cloud-config
autoinstall:
apt:
geoip: true
preserve_sources_list: false
primary:
- arches: [amd64, i386]
uri: http://us.archive.ubuntu.com/ubuntu
identity: {
hostname: <HOSTNAME>,
password: <PWHASH>,
realname: <USER>,
username: <USER>
}
user-data:
timezone: America/Los_Angeles
keyboard: {layout: us, toggle: null, variant: ''}
locale: en_US
network:
ethernets:
mainif:
match:
macaddress: <MAC>
set-name: eth0
eth0:
dhcp4: true
version: 2
ssh:
allow-pw: true
authorized-keys: [ <SSHKEY> ]
install-server: true
version: 1
I want to make it so that the user must change their password on first login.
Things I've tried:
Late command
curtin in-target --target=/target --passwd --expire <USER>
This fails because late commands apparently execute before users are created, even though the documentation says
Shell commands to run after the install has completed successfully and any updates and packages installed, just before the system reboots.`
The installer crashes, and I see in the crash report
/var/crash/$date.unknown.crash
that the command failed with exit status 1. Manually logging in, chrooting to /target, and trying the command confirms it, saying that user 'dan' doesn't exist, and it doesn't show up in /etc/passwd or /etc/shadow:
Using
chpasswd: {expire: True}
in the identity sectionThe installer crashes, saying that chpasswd is unexpected.
using bootcmd
This is silently ignored
using a late command to write a cron in /target
- /usr/bin/echo "@reboot root /usr/bin/passwd --expire dan && rm /etc/cron.d/update-pass" > /target/etc/cron.d/update-pass
This does the job, but seems super fragile and extremely difficult to maintain.
Does auto-installer have built-in functionality for this that I haven't found?