cloud-init how to add default user to sudoers.d
Asked Answered
A

1

4

I boot strap a centos 6.5 AMI with this user data:

#cloud-config
users:
  - default
  - name: my-user
  - sudo: ALL=(ALL) NOPASSWD:ALL

My machine comes up with the user cloud-user as the default user, not my-user. My public key has been copied to the cloud-user. So, in short, it does not work.

If I do this, the default user is my-user:

#cloud-config
user: my-user
sudo: ALL=(ALL) NOPASSWD:ALL

But I cannot sudo -i with this user.

How can I in userdata set my-user to be the default and have sudo provileges set?

Advertising answered 5/9, 2014 at 15:3 Comment(0)
A
2

You need to change the default user in system, see configuration below.

#cloud-config
system_info:
  default_user:
    name: my-user
    sudo: ALL=(ALL) NOPASSWD:ALL

I verified in openstack environment (should be the same)

  • ssh use my-user as default user with default private key
  • sudo is also ok

See http://cloudinit.readthedocs.org/en/latest/topics/examples.html#including-users-and-groups for more detail

Agnew answered 4/11, 2014 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.