cloud-init如何将默认用户添加到sudoers.d [英] cloud-init how to add default user to sudoers.d

查看:163
本文介绍了cloud-init如何将默认用户添加到sudoers.d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下用户数据引导了centos 6.5 AMI:

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

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

我的机器使用用户cloud-user作为默认用户,而不是my-user。我的公钥已复制到云用户。因此,简而言之,它不起作用。

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.

如果执行此操作,则默认用户为my-user:

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

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

但是我不能对此用户使用sudo -i。

But I cannot sudo -i with this user.

如何在userdata中设置我的-user是默认用户并设置了sudo provileges?

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

推荐答案

您需要在系统中更改默认用户,请参见以下配置。

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

我在openstack环境中进行了验证(应该是一样)

I verified in openstack environment (should be the same)


  • ssh使用my-user作为具有默认私钥的默认用户

  • sudo为也可以

请参见 http://cloudinit.readthedocs.org/en/latest/topics/examples.html#includes-users-and-groups 了解更多详细信息

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

这篇关于cloud-init如何将默认用户添加到sudoers.d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆