我知道这个问题已经被问了几次不行,不过,我仍然有问题W¯¯这里用户发布使用参考ansible doc文章ansible和密码设置不适用于ssh会话。ansible创建的密码对用户的SSH会话
我知道密码必须是散列而不是纯文本。我试过以下,但仍然无法SSH到远程主机。
---
- hosts: all #modify your server list
remote_user: root
vars:
#created using the sha-512
password: $6$i77J0vHI5M$/cWpyM72mGY5h8V6PW1KTg3Tjh6VH5jtdBTm2nLwjxKzW/iR2zbzm2X.eUYT833xEDaco5NxZgY.obtDNhPNz0
tasks:
- include_vars: users.yml
- name: Creating users to Jump Server
user: name="{{ item.username}}" password= "{{ password }}" state=present
with_items: "{{ users }}"
- name: Placing SSH Key to Authorized Key
#please note that this code assumes as if the public-private key pair is generated, all public users (created above) have public keys copied at one place i.e. keyfiles directory for the ease
authorized_key: user="{{item.username}}" key="{{ lookup('file', './keyfiles/authorized_keys.{{ item.username}}.pub')}}"
with_items: "{{ users }}"
/etc/shadow文件看起来像这样上的所有主机
[email protected]:/home# cat /etc/shadow | grep sam
sam::17393:0:99999:7:::
我在做什么错误或丢失?如果有人可以提出一些看法,我会感激。提前致谢。
行情没'乱七八糟的东西,这是你放在'='之后的空间,那是罪魁祸首。 – techraf