我需要能够在我的 Linux (Fedora 10) 上创建用户帐户并通过 bash 脚本(或其他方式,如果需要)自动分配密码。
通过 Bash 创建用户很容易,例如:
[whoever@server ]# /usr/sbin/useradd newuser
是否可以在 Bash 中分配密码,功能类似于此,但自动:
[whoever@server ]# passwd newuser
Changing password for user testpass.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[whoever@server ]#
最佳答案
您也可以使用 chpasswd :
echo username:new_password | chpasswd
因此,您将用户 username
的密码更改为 new_password
。
https://stackoverflow.com/questions/2150882/