我知道這個問題已經被問了幾次不行,不過,我仍然有問題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