Setting a root password via REST API

You were so close,

Generate your password like so (I use “ubuntu” as the password for this)

mkpasswd -m sha-512 -s <<< ubuntu

put the following in a file

#cloud-config
ssh_pwauth: yes
users:
 - name: james
   passwd: $6$wjMk.uTUi1tUX2cX$qn7plHDqzdlVLPc0Y5ruiTTpLGuPM5qpFls47v5Z3xGxxhpGx1QlAW2SR/aluE.kkmpITSWBsZq9J.za0iiJz.
   lock_passwd: false

create a profile
lxc profile create ssh-access

set the data
lxc profile set ssh-access user.user-data - < /path/to/above/file.yaml

create the container
lxc launch ubuntu: ssh -p default -p ssh-access

get the ip address
lxc list (find Ip)

ssh to host

ssh james@container_ip
password: ubuntu #if you copy and paste my yaml file above