ansible created password for a user does not work for ssh sessions -
i know question has been asked several times, however, still having issue where users created using ansible , password setup referenced ansible doc article not working ssh sessions.
i understand password has hashed rather plain text. tried following still can't ssh remote host.
--- - hosts: #modify server list remote_user: root vars: #created using sha-512 password: $6$i77j0vhi5m$/cwpym72mgy5h8v6pw1ktg3tjh6vh5jtdbtm2nlwjxkzw/ir2zbzm2x.euyt833xedaco5nxzgy.obtdnhpnz0 tasks: - include_vars: users.yml - name: creating users jump server user: name="{{ item.username}}" password= "{{ password }}" state=present with_items: "{{ users }}" - name: placing ssh key authorized key #please note code assumes if public-private key pair generated, public users (created above) have public keys copied @ 1 place i.e. keyfiles directory ease authorized_key: user="{{item.username}}" key="{{ lookup('file', './keyfiles/authorized_keys.{{ item.username}}.pub')}}" with_items: "{{ users }}" /etc/shadow looks on hosts
root@serverx:/home# cat /etc/shadow | grep sam sam::17393:0:99999:7::: what doing wrong or missing? appreciate if can put light. lot in advance.
you can use password variable directly instead of hash using password_hash filter:
your password variable:
password: "my_secure_password" then modified user creation task:
- name: creating users jump server user: name: "{{ item.username}}" password: "{{ password | password_hash('sha512') }}" state: present with_items: "{{ users }}"
Comments
Post a Comment