这是我的盐依赖项和系统版本:
#~: salt -V
Salt Version:
Salt: 3000
Dependency Versions:
cffi: 1.11.5
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.8
libgit2: Not Installed
M2Crypto: 0.29.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.10
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.18 (default, Apr 27 2020, 21:31:03) [GCC]
python-gnupg: Not Installed
PyYAML: 5.3.1
PyZMQ: 14.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.0.4
System Versions:
dist: SuSE 12 x86_64
locale: UTF-8
machine: x86_64
release: 4.12.14-122.136-default
system: Linux
version: SUSE Linux Enterprise Server 12 x86_64
我正在使用这样的主机名列表创建带有盐的大量用户列表:
for i in $(cat hostname_list.txt); do salt $i cmd.run "useradd -u 4441 -c \"John Doe \" -g 5900 -m jdoe" ; done ;
这种命令没有创建与用户登录相关的密码
我尝试使用此命令来创建密码,但它不起作用:
for i in $(cat hostname_list.txt); do salt $i user.passwd jdoe '<new Password>' ; done ;
我绕过了首先在一台主机上设置密码的问题,以便在 /etc/shadow 文件中 grep 加密密码并填充它:
for i in $(cat hostname_list.txt); do salt $i shadow.set_password jdoe 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
有没有一种解决方案,无需 grep 加密密码。
答案1
这是与 chpasswd 工具一起使用的
for i in $(cat hostname_list.txt); do salt $i cmd.run "echo 'jdoe:XXXXXXXX' | chpasswd" ; done ;