passwd 非交互修改密码

1. passwd –stdin username

1
2
3
echo '123456' | passwd --stdin test
Changing password for user test.
passwd: all authentication tokens updated successfully.

2. chpasswd

2.1. 指令行本地执行

1
echo 'test:123456' | chpasswd

2.2. 文档记录

1
2
3
4
5
cat passwd_file.txt
test1:123456
test2:654321
chpasswd < passwd_file.txt

3. openssl passwd -1

3.1. md5 普通加密

1
2
openssl passwd -1 123456
$1$1SUQ6TI2$unbG3IAUc2QLmCdANyn1L.

3.2. 加掩 & md5加密(使密文不可逆向破译)

1
2
openssl passwd -1 -salt "test" 123456
$1$test$at615QShYKduQlx5z9Zm7/