Question

On a precise64 box.

I tried creating a user with Chef using the following declaration:

user "myuser" do
  supports :manage_home => true
  shell "/bin/bash"
  home "/home/myuser"
  comment "Created by Chef"
  password "mypassword"
  system true
  provider Chef::Provider::User::Useradd
  action :create
end

This succeeds. I can find my user in /etc/passwd but the home directory wasn't created and I can authenticate.

$ su - myuser
su: Authentication failure

What am I missing?

Update

Found a similar thread here

Was it helpful?

Solution

Try the following

openssl passwd -1 "mypassword"

Password $1$YwUKq1QX$qIVeFlybWqOKJjRLed29j

user "myuser" do  
  supports :manage_home => true  
  shell "/bin/bash"  
  home "/home/myuser"  
  comment "Created by Chef"  
  password $1$YwUKq1QX$qIVeFlybWqOKJjRLed29j.  
  system true  
  provider Chef::Provider::User::Useradd  
  action :create  
end

OTHER TIPS

Chef hashes the password. Below bypasses it.

passwd=%x( openssl passwd -1 'mypassword' )
passwd.delete!("\n") # removes \n from string

user "myuser" do
  manage_home true
  shell "/bin/bash"
  comment "Created by Chef"
  password passwd
  system true
  provider Chef::Provider::User::Useradd
  action :create
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top