考虑这个简化的 ansible 任务,我使用加盐密码创建了一个用户:
// vars
name: "foo"
password: "pwd"
salt: "salt"
// task
- name: Setup users
user:
name: "{{ name }}"
password: '{{ password | string | password_hash("sha512", (salt | string | default(""))[:16] | regex_replace("[^\.\/a-zA-Z0-9]", "x")) }}'
state: present
shell: /bin/bash
update_password: always
一切都运行正常,直到几个月后服务器提示我更改密码,我当时很着急,所以我手动更改了密码……现在我试图在我的剧本上进行更改,但没有运气,我Incorrect sudo password
在收集事实时遇到了这种情况。我仔细检查了密码,可以确认我在服务器上使用的是同一个密码,我可以在服务器上正常使用sudo
。我应该怎么做才能匹配服务器上的密码?
编辑:
以下是发生错误时auth.log的内容:
Sep 18 21:18:30 myhost sshd[2256]: Connection from myIP port 33766 on serverIP port 22
Sep 18 21:18:31 myhost sshd[2256]: Postponed publickey for foo from myIP port 33766 ssh2 [preauth]
Sep 18 21:18:31 myhost sshd[2256]: Accepted publickey for foo from myIP port 33766 ssh2: ED25519 SHA256:FfrBJTV5NjTZwI0rMRPotXIz0KVUJxYtXBH4bQnQlXY
Sep 18 21:18:31 myhost sshd[2256]: pam_unix(sshd:session): session opened for user foo by (uid=0)
Sep 18 21:18:31 myhost systemd-logind[1272]: New session 21148 of user foo.
Sep 18 21:18:31 myhost sshd[2256]: User child is on pid 2335
Sep 18 21:18:32 myhost sshd[2335]: Starting session: command for foo from myIP port 33766 id 0
Sep 18 21:18:32 myhost sudo: pam_unix(sudo:auth): authentication failure; logname= uid=1001 euid=0 tty= ruser=foo rhost= user=foo
Sep 18 21:18:34 myhost sudo: pam_unix(sudo:auth): conversation failed
Sep 18 21:18:34 myhost sudo: pam_unix(sudo:auth): auth could not identify password for [foo]
Sep 18 21:18:34 myhost sudo: foo : 1 incorrect password attempt ; TTY=unknown ; PWD=/home/foo ; USER=root ; COMMAND=/bin/sh -c echo BECOME-SUCCESS-qaksizygaygpclmzkiyxtajmhinpwxlq ; /usr/bin/python3
Sep 18 21:18:34 myhost sshd[2335]: Close session: user foo from myIP port 33766 id 0