5.6. 指定其他用户
将用户添加到镜像中,并可选择设置其 SSH 密钥。本节的所有字段都是可选的,但 name 除外。
流程
自定义蓝图来将用户添加到镜像中:
[[customizations.user]] name = "USER-NAME" description = "USER-DESCRIPTION" password = "PASSWORD-HASH" key = "PUBLIC-SSH-KEY" home = "/home/USER-NAME/" shell = "/usr/bin/bash" groups = ["users", "wheel"] uid = NUMBER gid = NUMBER[[customizations.user]] name = "admin" description = "Administrator account" password = "$6$CHO2$3rN8eviE2t50lmVyBYihTgVRHcaecmeCk31L..." key = "PUBLIC SSH KEY" home = "/srv/widget/" shell = "/usr/bin/bash" groups = ["widget", "users", "wheel"] uid = 1200 gid = 1200 expiredate = 12345GID 是可选的,且必须在镜像中已存在。(可选)软件包会创建它,或者蓝图使用
[[customizations.group]条目创建 GID。将 PASSWORD-HASH 替换为实际的
密码哈希。要生成密码哈希,请使用如下命令:$ python3 -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass("Confirm: ")) else exit())'使用适当的值替换其他占位符。
输入
name值,并省略您不需要的任何行。为每个要包含的用户重复这个块。