linux --stdin 管道輸出


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM