创建用户的厨师食谱

Kev*_*ith 3 chef-infra

我想创建kevin一个密码为的新用户kevin.

食谱/ make_user /食谱/ default.rb

user "kevin" do
  comment "default user"
  home "/home/kevin"
  shell "/bin/bash"
  password "kevin"
end
Run Code Online (Sandbox Code Playgroud)

在配置我的Vagrant盒子之后,我将其放入盒子中.然而,我无法sukevin与密码的用户kevin.

[vagrant@vagrant-centos65 ~]$ su kevin
Password: 
su: incorrect password
Run Code Online (Sandbox Code Playgroud)

查看Chef'用户' 文档,我不确定这password是否是要修改的正确属性.

password    The password shadow hash. This attribute requires that 
            ruby-shadow be installed. This is part of the Debian package: 
            libshadow-ruby1.8.
Run Code Online (Sandbox Code Playgroud)

如何修改我上面的食谱,这样我可以sukevin使用相同的密码?

set*_*rgo 7

如文档中所示:http://docs.opscode.com/resource_user.html#password-shadow-hash,您需要使用OpenSSL生成阴影哈希:

openssl passwd -1 "theplaintextpassword"
Run Code Online (Sandbox Code Playgroud)

或者,如果您使用mkpasswd:

mkpasswd -m sha-512
Run Code Online (Sandbox Code Playgroud)