我想创建可以使用 cloudformation 模板用户数据访问实例的新 ssh 用户。我正在使用这个 json 脚本
"sudo adduser jenkins-user --disabled-password\n",
"sudo su - jenkins-user\n",
"\n",
"mkdir .ssh\n",
"chmod 700 .ssh\n",
"touch .ssh/authorized_keys\n",
"chmod 600 authorized_keys\n",
"cat >> /home/jenkins-user/.ssh/authorized_keys << end\n",
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKoORk6rbM4/0eDO0zBMWshXeibiuPQCP2KMl0fbyJTp9nCNngDG3qrIYBvU4TdOCXF\n", "\n",
"end\n"
当我检查 cloud-init-output.log 时出现此错误
adduser jenkins-user --disabled-password
Adding user `jenkins-user' ...
Adding new group `jenkins-user' (1001) ...
Adding new user `jenkins-user' (1001) with group `jenkins-user' ...
Creating home directory `/home/jenkins-user' ...
Copying files from `/etc/skel' ...
Changing the user information for jenkins-user
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []: Use of uninitialized value $answer in chop at /usr/sbin/adduser line 589.
Use of uninitialized value $answer in pattern match (m//) at /usr/sbin/adduser line 590.
Is the information correct? [Y/n] sudo su - jenkins-user
有人可以帮我弄这个吗?
答案1
adduser 是交互式的,切换到用户添加。
useradd 是随系统编译的本机二进制文件。但是,adduser 是一个在后端使用 useradd 二进制文件的 perl 脚本。
adduser 比其后端 useradd 更加用户友好且交互性更强。提供的功能没有区别。
https://superuser.com/questions/547966/whats-the-difference-between-adduser-and-useradd