Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I create a user on ubuntu VM via cloud init?

I'm able to ssh into my Ubuntu VMs and modify some things via cloud init, such as adding proxies and installing packages, but I'd like to create users with cloud init. However, if I try to create a user with cloud init and then ssh in, my key is rejected. I've tried to include the key into the cloud config as below:

users:
  - name: newuser
    ssh-authorized-keys: <key>
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash

This allows me to ssh into the machine but then the user is not actually created (at least, it is not in /etc/passwd). What am I doing wrong?

How can I create a user on ubuntu VM via cloud init?

I'm able to ssh into my Ubuntu VMs and modify some things via cloud init, such as adding proxies and installing packages, but I'd like to create users with cloud init. However, if I try to create a user with cloud init and then ssh in, my key is rejected. I've tried to include the key into the cloud config as below:

users:
  - name: newuser
    ssh-authorized-keys: 
       - <key>
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash

This allows me to ssh into the machine but then the user is not actually created (at least, it is not in /etc/passwd). What am I doing wrong?