【问题标题】:Adding a new user in Ubuntu using cloud init fails使用 cloud init 在 Ubuntu 中添加新用户失败
【发布时间】:2023-01-14 08:37:44
【问题描述】:

我正在尝试为我的几台运行 Ubuntu 22.04 服务器的 Ubuntu 机器设置一些默认设置。这是我的配置:

#cloud-config
ssh_pwauth: false

groups:
  - mygrp: [myuser]

users:
  - name: myuser
    gecos: myuser
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups: sudo
    ssh_import_id: None
    lock_passwd: true
    shell: /bin/bash
    # Replace the <ssh-pub-key> with the actual SSH public key
    ssh_authorized_keys:
      - <ssh-pub-key>

hostname: my-host-1

当我运行它时,我看到以下错误:

2023-01-13 16:12:27,398 - __init__.py[WARNING]: Skipping creation of existing group 'mygrp'
2023-01-13 16:12:27,403 - __init__.py[WARNING]: Unable to add group member 'myuser' to group 'mygrp'; user does not exist.

我的这个脚本有什么问题?

【问题讨论】:

    标签: ubuntu cloud-init


    【解决方案1】:

    组在用户之前添加,因此组列表中的任何用户必须已经存在于系统中。

    https://cloudinit.readthedocs.io/en/latest/reference/modules.html#users-and-groups

    【讨论】:

      猜你喜欢
      • 2016-01-20
      • 2017-07-02
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-19
      • 2022-01-16
      • 2023-03-21
      相关资源
      最近更新 更多