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

Linux下利用shell腳本隨機生成密碼
首先,安裝expect
yum install expect
生成方式,我們介紹二種,一是命令行方式,二是shell腳本方式。
(1)命令行生成隨機密碼
mkpasswd -l 14 -s 2 -c 3 -C 3 -d 4
生成一個14位的密碼,至少包含2個特殊字符,3個小寫字母,3個大寫字母和4個數(shù)字。
(2)編寫shell腳本,批量生成30個密碼
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)
指定密碼的長度,默認是7位數(shù)
-d # (min # of digits, default = 2)
指定密碼中數(shù)字最少位數(shù),默認是2位
-c # (min # of lowercase chars, default = 2)
指定密碼中小寫字母最少位數(shù),默認是2位
-C # (min # of uppercase chars, default = 2)
指定密碼中大寫字母最少位數(shù),默認是2位
-s # (min # of special chars, default = 1)
指定密碼中特殊字符最少位數(shù),默認是1位
當前文章:Linux中通過shell腳本隨機生成密碼具體方法
本文URL:http://m.fisionsoft.com.cn/article/cceejgs.html


咨詢
建站咨詢
