--stdin  

This option is used to indicate that passwd should read the new password from standard input, which can be a pipe.  

这个选项用于从标准输入管道读入新的密码。 

使用 echo 方式来重置Linux 系统用户密码:

echo “新密码”|passwd --stdin 用户名

1
2
3
4
5
6
7
8
9
10
[root@rhel7 ~]# passwd --stdin rusky   为rusky用户设置密码。
Changing password for user rusky.
zxcvbnm
passwd: all authentication tokens updated successfully.
[root@rhel7 ~]# echo "qwert"
qwert
[root@rhel7 ~]# echo "qwert" | passwd --stdin rusky  把echo返回的字符qwert设置为用户rusky的密码
Changing password for user rusky.
passwd: all authentication tokens updated successfully.
[root@rhel7 ~]#

这种方式虽然简单,但是通过history命令可以查到用户的密码,所以不安全。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-05-05
  • 2022-01-19
  • 2021-11-03
  • 2021-06-25
  • 2021-06-22
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2021-06-30
  • 2021-10-05
  • 2022-12-23
  • 2021-12-22
  • 2021-08-25
相关资源
相似解决方案