linux shell mkpasswd generates random password

The mkpasswd command generates a random password. 

Parameters: 

-l # (the length of the password is defined, the default is 9) 
-d # (the number of digits, the default is 2) 
-c # (the number of lowercase characters, the default is 2) 
-C # (uppercase Number of characters, default is 2) 
-s # (number of special characters, default is 1) 
-v (detailed...) 
-p prog (program setting password, default is passwd)

Example 1:

[root@CnDkL01 ~]# mkpasswd -l 20	 #生成随机密码同时制定长度为20
mMgfg7bfH~5irgacvqna

[root@CnDkL01 ~]# mkpasswd 		 #生成默认长度随机密码
4kaxd2$WV

[root@CnDkL01 ~]# mkpasswd -d 3	 #生成指定数字位数的密码
ob4e}1NL2

#为用户更改随机密码,当然如果想知道生成的密码需要配合shell来操作,这种方法适用于为很多用户修改随机密码。
[root@CnDkL01 ~]# echo `mkpasswd -l 10` | passwd --stdin chenliang 

Example 2:

# 生成密码长度10,数字2个,小写3个,大写3个,特殊2个
mkpasswd  -l 10 -d 2 -c 3 -C 3 -s 2  
W'.Ix5Kvd1

# 生成 无特殊符号的密码
mkpasswd -s 0
yVk7Keju9

 

 

Guess you like

Origin blog.csdn.net/whatday/article/details/113837807