Managing a user password for linux in puppet

后端 未结 8 971
心在旅途
心在旅途 2020-12-07 16:00

I need to create a test user with a password using puppet.

I\'ve read that puppet cannot manage user passwords in a generic cross-platform way, which is a pity. I am

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 16:17

    Linux users have their passwords stored as hash in /etc/shadow file. Puppet passes the password supplied in the user type definition in the /etc/shadow file.

    Generate your hash password using openssl command:

     #openssl passwd -1  
     #Enter your password here 
     Password: 
     Verifying - Password: 
     $1$HTQUGYUGYUGwsxQxCp3F/nGc4DCYM
    

    The previous example generate this hash: $1$HTQUGYUGYUGwsxQxCp3F/nGc4DCYM/

    Add this hash password to your class as shown (do not forget the quotes)

    user { 'test_user': 
      ensure   => present,
      password => '$1$HTQUGYUGYUGwsxQxCp3F/nGc4DCYM/',
    }
    

提交回复
热议问题