新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Linux中通過(guò)shell腳本隨機(jī)生成密碼具體方法
本篇文章大家講解一下Linux中通過(guò)shell腳本的方式隨機(jī)生成密碼具體方法,有需要的小伙伴可以參考一下。

Linux下利用shell腳本隨機(jī)生成密碼
首先,安裝expect
yum install expect
生成方式,我們介紹二種,一是命令行方式,二是shell腳本方式。
(1)命令行生成隨機(jī)密碼
mkpasswd -l 14 -s 2 -c 3 -C 3 -d 4
生成一個(gè)14位的密碼,至少包含2個(gè)特殊字符,3個(gè)小寫(xiě)字母,3個(gè)大寫(xiě)字母和4個(gè)數(shù)字。
(2)編寫(xiě)shell腳本,批量生成30個(gè)密碼
vi mkpasswd.sh
\#!/bin/bash
i=1
echo "########kim by 51cto.com##########" >/tmp/passwd.txt
while [ $i -le 30 ];do
/usr/bin/mkpasswd -l 14 -s 2 -c 3 -C 3 -d 4 >>/tmp/passwd.txt
let i+=1
done
exit;
(3)mkpasswd參數(shù)詳解
-l # (length of password, default = 7)
指定密碼的長(zhǎng)度,默認(rèn)是7位數(shù)
-d # (min # of digits, default = 2)
指定密碼中數(shù)字最少位數(shù),默認(rèn)是2位
-c # (min # of lowercase chars, default = 2)
指定密碼中小寫(xiě)字母最少位數(shù),默認(rèn)是2位
-C # (min # of uppercase chars, default = 2)
指定密碼中大寫(xiě)字母最少位數(shù),默認(rèn)是2位
-s # (min # of special chars, default = 1)
指定密碼中特殊字符最少位數(shù),默認(rèn)是1位
網(wǎng)站題目:Linux中通過(guò)shell腳本隨機(jī)生成密碼具體方法
網(wǎng)頁(yè)鏈接:http://www.5511xx.com/article/cceejgs.html


咨詢
建站咨詢
