一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Linux - 詳解Linux下隨機生成密碼的命令總結

詳解Linux下隨機生成密碼的命令總結

2022-01-12 17:56瀟湘隱者 Linux

本文詳細介紹了如何使用Linux下命令來隨機生成安全、符合密碼復雜度的命令。 非常具有實用價值,需要的朋友可以參考下

有時候經常為如何設置一個安全、符合密碼復雜度的密碼而絞盡腦汁,說實話,這實在是一個體力活而且浪費時間,更重要的是設置密碼的時候經常糾結。終于有一天實在忍不住了,于是學習、整理了一下如何使用linux下命令來隨機生成安全、符合密碼復雜度的命令。

俗話說“工欲善其事必先利其器”。如果能用挖土機的,你為什么要用鋤頭? 最近一直在反思自己:習慣性用原始、老舊的方式解決問題。而不擅長利用一些工具快捷、方便的解決問題。

 1:mkpaswd命令 

mkpasswd 是linux自帶的一個密碼生成工具,可以說是非常安全、可靠的(如果你擔心一些在線的隨機密碼生成工具,會收集、記錄你生成的密碼的話)。個人非常喜歡這個工具的原因就是它可以設置生成密碼的復雜度。另外,它不僅可以隨機幫你生成密碼,還可以直接幫你修改相關賬號密碼。如果你找不到這個命令,那么可能你沒有安裝expect包。

方式1: yum安裝方式。

?
1
yum -y install expect

方式2: rpm安裝方式。

?
1
2
3
4
5
6
[root@db-server server]# ls *expect*
expect-5.43.0-5.1.i386.rpm expect-5.43.0-5.1.x86_64.rpm expect-devel-5.43.0-5.1.i386.rpm expect-devel-5.43.0-5.1.x86_64.rpm expectk-5.43.0-5.1.x86_64.rpm pexpect-2.3-3.el5.noarch.rpm
[root@db-server server]# rpm -ivh expect-5.43.0-5.1.x86_64.rpm
warning: expect-5.43.0-5.1.x86_64.rpm: header v3 dsa signature: nokey, key id 37017186
preparing...        ########################################### [100%]
  1:expect         ########################################### [100%]

關于mkpasswd命令的一些參數,如下所示:

 

參數
    功能描述
-l
定義生成密碼的長度,默認9
-d
定義密碼里面包含數字的最少個數,默認2
-c
定義密碼里面包含小寫字母的最少個數,默認2
-c
定義密碼里面包含大寫字母的最少個數,默認2
-s
定義密碼密碼包含特殊字符的最少個數,默認1
-p
指定另外一個生成密碼的程序,默認是/etc/yppasswd

 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@db-server server]# mkpasswd -l 14 -d 2 -c 2 -s 2 -v kerry
spawn passwd kerry
passwd: unknown user name 'kerry'.
password for kerry is 1s[(qillert8xf
[root@db-server server]# mkpasswd -l 14 -d 2 -c 2 -s 2 -v test
spawn passwd test
passwd: unknown user name 'test'.
password for test is 1ar1t$-qwihcrb
[root@db-server server]# mkpasswd -l 14 -d 2 -c 2 -s 2 -v oracle
spawn passwd oracle
changing password for user oracle.
new unix password:
retype new unix password:
passwd: all authentication tokens updated successfully.
password for oracle is 24_vfkxqsol^pr
[root@db-server server]#
 
[root@db-server server]# mkpasswd -l 14 -d 2 -c 2 -s 2 oracle
i&jijfgb92*fda
[root@db-server server]#

詳解Linux下隨機生成密碼的命令總結

 2:apg命令

apg是一款開源免費的密碼隨機生成器,官方網址為

安裝方式:

1:ubuntu下的apt-get方式:

?
1
sudo apt-get install apg

2:使用rpm方式:

?
1
2
3
4
5
[root@db-server tmp]# rpm -ivh apg-2.2.3-3.el5.rf.i386.rpm
warning: apg-2.2.3-3.el5.rf.i386.rpm: header v3 dsa signature: nokey, key id 6b8d79e6
preparing...        ########################################### [100%]
  1:apg          ########################################### [100%]
[root@db-server tmp]#

關于apg命令的一些參數,如下所示:

 

參數
    功能描述
-m
生成密碼的模式
-e
生成密碼過程中排除字符串
-r
apply dictionary check against file
-b
 
-p
paranoid modifier for bloom filter check
-a
1: 隨機密碼生成模式。  0:可發音的密碼生成
-n
包含數字,但是不是每個密碼都有
-n
每個密碼都必須包含數字
-m
生成密碼最小長度,默認為8,實際生成的隨機密碼長度都可能超過這個值
-x
生成密碼最大長度。
-s
包含特殊字符,但是不一定每個都有
-s
每個密碼都必須有特殊字符
-c
包含大寫字母。
-c
每個密碼都必須包含小寫字母
-d
 在生成的密碼中間不加任何分割符,默認6個密碼連成一長串
-l
生成密碼的spell
-t
輸出密碼中可發音字符的發音
-y
輸出加密密碼
-q
靜默模式,不輸出告警信息
-h
輸出幫助信息
-v
版本信息。

 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@db-server ~]#
[root@db-server ~]# apg -m sncl -m 8 -x 12
cupif6swib?
kij/ovmuk7
cyn=otduif1
eic3enn>
newcod"rab4
{flipnayt0
[root@db-server ~]# apg -m sncl -m 8 -x 12 -t
dujghitt6ob` (duj-ghitt-six-ob-grave)
rewgemec7ow~ (rewg-em-ec-seven-ow-tilde)
oc%knegg1 (oc-percent_sign-knegg-one)
loon5quem+ (loon-five-quem-plus_sign)
el5bleb{ (el-five-bleb-left_brace)
te4qued( (te-four-qued-left_parenthesis)

3:pwgen

pwgen生成的密碼容易記憶而且安全。pwgen的下載地址為https://sourceforge.net/projects/pwgen-win/files/pwgen/2.9.0/

apt-get install pwgen

關于pwgen命令的一些參數,如下所示:參數說明:

 

參數
    功能描述
-c
密碼里面包含至少一個大寫字母
-a
密碼里面不包含大寫字母
-n
密碼里面至少包含一個數字。
-0
密碼中不包含數字
-y
密碼中至少包含一個特殊字符。
-s
生成安全隨機的密碼
-b
密碼中不包含混淆的字符,例如“1”和“i”
-h
查看幫助信息
-h
使用指定文件sha1哈希生成,不適用隨機生成
-c
按列打印生成的隨機密碼
-1
每行輸出一個密碼,不按列打印生成密碼
-v
密碼不包括元音字母或者可能被誤認為是元音字母的數字

 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
root@db-server:~# pwgen -h
usage: pwgen [ options ] [ pw_length ] [ num_pw ]
 
options supported by pwgen:
 -c or --capitalize
    include at least one capital letter in the password
 -a or --no-capitalize
    don't include capital letters in the password
 -n or --numerals
    include at least one number in the password
 -0 or --no-numerals
    don't include numbers in the password
 -y or --symbols
    include at least one special symbol in the password
 -s or --secure
    generate completely random passwords
 -b or --ambiguous
    don't include ambiguous characters in the password
 -h or --help
    print a help message
 -h or --sha1=path/to/file[#seed]
    use sha1 hash of given file as a (not so) random generator
 -c
    print the generated passwords in columns
 -1
    don't print the generated passwords in columns
 -v or --no-vowels
    do not use any vowels so as to avoid accidental nasty words
 
root@db-server:~# pwgen -c
xu3aiquu choo2aij ohch3eip ou8ofeel ayai5thi iet3eene ieth1dei mairah0o
gad9ooth fabohz6e oojee3oo thiec4ah ahb1iedi sah7ahth kainee4o beew7eew
eedoha1b eom3aiph daigee2i aog4gei8 siejoo9o eemahk6a erur1aim ohbu6thi
ae0ohbai ehai9go0 ni0iye4k ais0eedo ki3aiku4 cue7aexi ao3lae5o oot2ahth
yiev2lei ingeeth5 aebi1sai quahh0ei wei3aep5 bohng8ae eecuor5i kie1eith
hiepa7th uchaith5 eix5echi reir4ele rawaic5l ahk6fae1 eid5aen2 saep4voh
irea6quo iakoh7pi eiphoo1o pie9neir aj2thied mi3shugh oingi8oo vohthoo3
eph6eed1 ibooc3ux wo5tapha ceigh8ah eex7ae6r aeb1phoo zohquo9h ahphaig5
daenu0ue qui2feph quet5wo7 fooquo1m vei4ceej nie3nae2 ipahla7e ku6ahbuf
oong2ye8 eij2haej ohchie4i oowah4oz utaim8sh hah3oong iequ1pai aewai8mi
waip3aiz hi0se4ai boon0azi ir0eicee theeth5n aefo4air tah7teef aogh3quo
iya6eigo ie9heegh aeyoh9bo eixoos4z yez7obai doosei4w sapeebe8 ood1cahc
ie5ohf1s goonoob2 aiy9wu7w oeh3sa5v eith9vai iyahs1fu she5oogi kohsha7e
deeleit4 eibie0th ou4deihi pai0oluk vae6baih doocee5e ahd2iex3 eil9airu
zeinou0c uu4bairi ahx2eew2 ashai0ee yae0aita paph4air ich4nei4 mooph1ch
ez0aitha hoo8gaeh aitha3ga quaif7ei iel9oafu cai0id2u eecul0qu oochae0a
vuk1she4 bai3ohte aichah9v mohz7iyo zaeyoo8j xah4ohhi ohz1ohw6 eed0aeko
tooqu3ar eih8rata wiech2ub nomooch6 ahv8boo3 zea2gei4 oam4eile cier9iev
baereef9 iom2the0 foe3ieza zaingat4 do1bah7r atuyom2u eequ1lie chaexo2j
eiza0aed leimuol0 eid5yu5c ahp4ahtu oobiesh2 av8iaxoh yeid0eej goor1aey
root@db-server:~# pwgen -1
au9ni2fa

詳解Linux下隨機生成密碼的命令總結

生成一個10個長度包含大小字母,數字、特殊字符的密碼:

?
1
2
3
root@db-server:~# pwgen -1cny 10
 
the9ciep#a

生成12個密碼長度為10,并且至少包含一個特殊字符、數字、大寫字母的密碼

?
1
2
3
4
5
6
7
8
9
10
11
12
13
root@db-server:~# pwgen -cy -1 -n 10 12
cahw]ie7ug
nie1ooko-u
anguu4iu!n
hie%m2ojeh
be7wo{w:ah
ee^quaif2u
lo{ngia1ce
aetoh"d7ah
ies5cho=ch
lu4seey<ab
si>or.aih6
eo;l6fie1m

詳解Linux下隨機生成密碼的命令總結

當然還有一些其它密碼生成工具,例如makepasswd、passwordmaker-cli 。個人覺得工具的掌握在精不在多,熟練掌握一兩款工具即可。網上有篇用linux命令行生成隨機密碼的十種方法, 里面介紹了很多種生成密碼的工具和方法,只是有些命令和方法非常不實用。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:http://www.cnblogs.com/kerrycode/p/6537175.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 99热免费在线观看 | 韩国女主播一区二区视频 | 婷婷色天使在线视频观看 | 深夜福利在线播放 | 国产欧美日韩精品高清二区综合区 | 奇米影视小说 | 深夜免费在线观看 | 国产自一区 | 亚洲成综合 | 欧美成人禁片在线观看俄罗斯 | 人与善交大片免费看 | 91精品国产亚一区二区三区 | 久久无码人妻AV精品一区 | 国产另类视频一区二区三区 | 国产精品一区二区在线观看完整版 | 男人桶女下面60分钟视频 | 好爽好舒服视频 | 久久久精品成人免费看 | 女主被男主做哭失禁高h | 精品欧美一区二区三区久久久 | 亚洲国产精品网站久久 | 国产japanese孕妇孕交 | 亚洲国产成人超福利久久精品 | 西西人体大胆啪啪私拍色约约 | 国产chinese男同gay | 国产成人无精品久久久久国语 | 免费黄色片网站 | 奇米影视先锋 | 亚州人成网在线播放 | 99国产自偷色久 | 亚洲国产欧美在线人成 | 亚洲欧美专区精品久久 | 国产成人免费在线视频 | 91色视 | 午夜欧美福利视频 | 欧美一区二区三区精品国产 | 欧美性色老妇人 | 欧美夫妇野外交换hd高清版 | 亚洲免费在线看 | 国产suv精品一区二区四区三区 | 99久久香蕉 |