-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 用戶名
[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命令可以查到用戶的密碼,所以不安全。
今日推薦