首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >云-配置-自动安装-根密码

云-配置-自动安装-根密码
EN

Ask Ubuntu用户
提问于 2022-07-19 14:57:48
回答 1查看 2.4K关注 0票数 1

我正在尝试用云init安装ubuntu20.4,我想为root配置密码,所以我尝试了这个选项,但它没有工作。(vmware机器登录其形式同意)

代码语言:javascript
复制
UPDATE-

这个选择对我来说是可行的。(谢谢安德鲁·洛瑟)

代码语言:javascript
复制
user-data:
    chpasswd:
      list: |
      expire: false
      list:
        - root:$6$bababa   

                                                                                                            


#cloud-config
    autoinstall:
      version: 1
      apt:
        disable_components: []
        geoip: true
        preserve_sources_list: false
        primary:
        - arches:
          - amd64
          - i386
          uri: http://archive.ubuntu.com/ubuntu
        - arches:
          - default
          uri: http://ports.ubuntu.com/ubuntu-ports
      identity:
        hostname: my-hostname
        password: $6$baagagagagaa$ewAe9SRZlS2q6yxYtvyJ0u.Lu4l6pgSf5uisgagajlOVTjBfuBb4QIQekfaToA1DtKAUCjoiiAEyc5VYj26uS1
        realname: scadmin
        username: scadmin
      user-data:
        chpasswd:
          expire: false
          list:
            - root: $6$2mzNTlBmwfafad$0liKgagaoGfafafblalblalJQAbloalblalaFmw2m9fNXHHSZvw3zSfYH/sAA2P/kcTG8wruhLI6WWWzFaMiTEblHnfF8hQQPtxRs.
      kernel:
        package: linux-generic
      keyboard:
        layout: us
        toggle: null
        variant: ''
      locale: en_US.UTF-8
      network:
        network:
          version: 2
          ethernets:
            ens160:
              dhcp4: yes
              dhcp-identifier: mac
      ssh:
        allow-pw: true
        authorized-keys: []
        install-server: true
      storage:
        config:
        - ptable: gpt
          path: /dev/sda
          wipe: superblock-recursive
          preserve: false
          name: ''
          grub_device: true
          type: disk
          id: disk-sda
        - device: disk-sda
          size: 1048576
          flag: bios_grub
          number: 1
          preserve: false
          grub_device: false
          type: partition
          id: partition-0
        - device: disk-sda
          size: 30064771072
          wipe: superblock
          flag: ''
          number: 2
          preserve: false
          grub_device: false
          type: partition
          id: partition-1
        - name: vg0
          devices:
          - partition-1
          preserve: false
          type: lvm_volgroup
          id: lvm_volgroup-0
        - device: disk-sda
          size: 2144337920
          wipe: superblock
          flag: ''
          number: 3
          preserve: false
          grub_device: false
          type: partition
          id: partition-3
        - fstype: ext4
          volume: partition-3
          preserve: false
          type: format
          id: format-0
        - name: lv-swap
          volgroup: lvm_volgroup-0
          size: 4294967296B
          wipe: superblock
          preserve: false
          type: lvm_partition
          id: lvm_partition-0
        - name: lv-root
          volgroup: lvm_volgroup-0
          size: 25765609472B
          wipe: superblock
          preserve: false
          type: lvm_partition
          id: lvm_partition-1
        - fstype: ext4
          volume: lvm_partition-1
          preserve: false
          type: format
          id: format-3
        - path: /
          device: format-3
          type: mount
          id: mount-3
        - fstype: swap
          volume: lvm_partition-0
          preserve: false
          type: format
          id: format-4
        - path: ''
          device: format-4
          type: mount
          id: mount-4
        - path: /boot
          device: format-0
          type: mount
          id: mount-0
      updates: security
      packages:
        - open-vm-tools
      late-commands:
        - |
          cat < /target/etc/cloud/cloud.cfg.d/80_my.cfg
          hostname: $(openssl rand -hex 3)
          manage_etc_hosts: true
          preserve_hostname: false
          EOF
EN

回答 1

Ask Ubuntu用户

发布于 2022-07-19 16:12:08

如果您有一个identity节,那么users部分就不会被使用。users密钥也位于user-data密钥之下。请参阅https://askubuntu.com/a/1385096/376778

您不需要创建root用户。你只需要设置它的密码。我使用了这个部分user-data配置来设置根密码。这应该适用于本地登录(例如vmware控制台),但是需要额外的配置才能允许远程登录(例如ssh)。

代码语言:javascript
复制
#cloud-config
autoinstall:
  user-data:
    chpasswd:
      expire: false
      list:
        - root:$6$REDACTED
票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1419481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档