TAGS :Viewed: 9 - Published at: a few seconds ago

[ cloud-init .yaml script on Digital Ocean droplets ]

I am stuck with creating users with Cloud-Config.

Did anyone succeed and can share a .yaml gist to create a new user with ssh-authorized-keys and ability to sudo?

Answer 1

This article on DigitalOcean runs through doing some of the most common initial tasks using cloud-config files.

Setting up a new sudo user would look like this:

  - name: username
      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv60WjxoM39LgPDbiW7ne3gu18q0NIVv0RE6rDLNal1quXZ3nqAlANpl5qmhDQ+GS/sOtygSG4/9aiOA4vXO54k1mHWL2irjuB9XbXr00+44vSd2q/vtXdGXhdSMTf4/XK17fjKSG/9y3yD6nml6 user@example.com
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash

Of course, replace the ssh key with your public key.