使用mkpasswd生成隨機密碼

君落塵發表於2015-03-13

1、使用yum安裝

# yum -y install expect
Loaded plugins: fastestmirror, security
Determining fastest mirrors
 * base: mirrors.yun-idc.com
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
base                                                                                                                                                                  | 3.7 kB     00:00     
extras                                                                                                                                                                | 3.4 kB     00:00     
extras/primary_db                                                                                                                                                     |  30 kB     00:00     
updates                                                                                                                                                               | 3.4 kB     00:00     
updates/primary_db                                                                                                                                                    | 2.6 MB     00:04     
Setting up Install Process
Resolving Dependencies
--&gt Running transaction check
---&gt Package expect.x86_64 0:5.44.1.15-5.el6_4 will be installed
--&gt Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================
 Package                                    Arch                                       Version                                                Repository                                Size
=============================================================================================================================================================================================
Installing:
 expect                                     x86_64                                     5.44.1.15-5.el6_4                                      base                                     256 k

Transaction Summary
=============================================================================================================================================================================================
Install       1 Package(s)

Total download size: 256 k
Installed size: 553 k
Downloading Packages:
expect-5.44.1.15-5.el6_4.x86_64.rpm                                                                                                                                   | 256 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : expect-5.44.1.15-5.el6_4.x86_64                                                                                                                                           1/1 
  Verifying  : expect-5.44.1.15-5.el6_4.x86_64                                                                                                                                           1/1 

Installed:
  expect.x86_64 0:5.44.1.15-5.el6_4                                                                                                                                                          

Complete!
2、檢視引數設定
usage: mkpasswd [args] [user]
  where arguments are:
    -l #      (length of password, default = 9)
    -d #      (min # of digits, default = 2)
    -c #      (min # of lowercase chars, default = 2)
    -C #      (min # of uppercase chars, default = 2)
    -s #      (min # of special chars, default = 1)
    -v        (verbose, show passwd interaction)
    -p prog   (program to set password, default = passwd)

引數:

-l # (密碼的長度定義, 預設是 9)

-d # (數字個數, 預設是 2)

-c # (小寫字元個數, 預設是 2)

-C # (大寫字元個數, 預設是 2)

-s # (特殊字元個數, 預設是 1)

-v (詳細。。。)

-p prog (程式設定密碼, 預設是 passwd)

3、開始設定root使用者的密碼,使用新密碼登入測試下。

密碼長度20,數字5個,小寫5個,大寫5個,特殊5個
#  mkpasswd  -l 20 -d 5 -c 5 -C 5 -s 5 root
Z}K7hp0UPJ6v@&,c5{d3






來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29819001/viewspace-1458191/,如需轉載,請註明出處,否則將追究法律責任。

相關文章