Ubuntu下如何生成随机密码?
如何使用Ubuntu下命令来随机生成安全、符合密码复杂度的命令。
1:apg命令
apg是一款开源免费的密码随机生成器,官方网址为http://www.adel.nursat.kz/apg/
安装方式:
1:Ubuntu下的apt-get方式:
1 |
sudo apt-get install apg |
2:使用RPM方式:
1 |
[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 6b8d79e6Preparing... ########################################### [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 |
[root@DB-Server ~]# [root@DB-Server ~]# apg -M SNCL -m 8 -x 12 Cupif6Swib?Kij/OvMuk7cyn=OtDuIf1eic3Enn>newCod"Rab4{Flipnayt0[root@DB-Server ~]# apg -M SNCL -m 8 -x 12 -tdujghitt6Ob` (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) |
2:pwgen
pwgen生成的密码容易记忆而且安全。pwgen的下载地址为https://sourceforge.net/projects/pwgen-win/files/PWGen/2.9.0/
1 |
apt-get install pwgen |
关于pwgen命令的一些参数,如下所示:参数说明:
参数 | 功能描述 |
-c | 密码里面包含至少一个大写字母 |
-A | 密码里面不包含大写字母 |
-n | 密码里面至少包含一个数字。 |
-0 | 密码中不包含数字 |
-y | 密码中至少包含一个特殊字符。 |
-s | 生成安全随机的密码 |
-B | 密码中不包含混淆的字符,例如“1”和“I” |
-h | 查看帮助信息 |
-H | 使用指定文件sha1哈希生成,不适用随机生成 |
-C | 按列打印生成的随机密码 |
-1 | 每行输出一个密码,不按列打印生成密码 |
-v | 密码不包括元音字母或者可能被误认为是元音字母的数字 |
1 |
root@DB-Server:~# pwgen -hUsage: 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 -CXu3aiQuu choo2Aij ohCh3eip ou8ofeeL aYai5thi iet3eeNe ieth1Dei Mairah0ogad9ooTh faBohZ6e ooJee3Oo Thiec4ah ahb1Iedi Sah7ahth Kainee4o beew7EeWEedoHa1B eom3Aiph daigee2I AoG4Gei8 Siejoo9o Eemahk6a erur1Aim ohbu6Thiae0Ohbai Ehai9go0 ni0iYe4k Ais0eedo Ki3Aiku4 cue7AeXi Ao3lae5o oot2ahThyiev2Lei iNgeeth5 aeBi1sai quahh0Ei wei3aeP5 Bohng8ae Eecuor5i kie1eiThhiepa7Th uchaiTh5 eiX5Echi reiR4ele RaWaic5l Ahk6fae1 eiD5aen2 saep4Vohirea6Quo Iakoh7pi eiPhoo1o pie9NeiR aj2Thied Mi3shugh oingi8Oo Vohthoo3eph6Eed1 Ibooc3ux wo5TaPha Ceigh8aH eeX7ae6r aeB1phoo zohquo9H ahPhaig5daenu0Ue qui2Feph queT5wo7 fooquo1M Vei4ceej Nie3nae2 IpahLa7e Ku6ahbufOong2ye8 eiJ2haej ohChie4i oowah4Oz utaiM8Sh hah3Oong ieQu1pai aewai8Miwaip3Aiz Hi0se4ai boon0AZi iR0eicee theeTh5n aeFo4air Tah7teef Aogh3QuoIya6eigo ie9Heegh aeyoh9Bo eiXoos4z YeZ7obai doosei4W sapeeBe8 ood1CahCie5ohF1s Goonoob2 aiy9Wu7W Oeh3sa5v EiTh9vai iyahs1Fu she5Oogi kohsha7EDeeleit4 eibie0Th ou4Deihi Pai0oluk Vae6baih Doocee5e ahD2iex3 eil9aiRuzeiNou0C uu4baiRi ahx2Eew2 Ashai0Ee Yae0aita paph4Air Ich4nei4 Mooph1CheZ0AiTha Hoo8gaeh aiTha3Ga Quaif7ei Iel9oafu Cai0iD2u EeCuL0qu oochae0Avuk1She4 Bai3Ohte aiChah9v Mohz7iYo zaeyoo8J xah4ohHi ohZ1ohw6 Eed0aeKotooQu3ar eiH8rata wiech2UB noMooch6 ahv8Boo3 zea2Gei4 oaM4Eile Cier9ieVbaeReef9 Iom2the0 Foe3ieza zaiNgat4 do1Bah7R ATuyom2u EeQu1lie chaeXo2jeiza0Aed Leimuol0 eid5yu5C ahp4ahTu OobieSh2 Av8Iaxoh yeid0Eej gooR1aeYroot@DB-Server:~# pwgen -1au9ni2Fa |
生成一个10个长度包含大小字母,数字、特殊字符的密码:
1 |
root@DB-Server:~# pwgen -1cny 10 The9ciep#a |
生成12个密码长度为10,并且至少包含一个特殊字符、数字、大写字母的密码
1 |
root@DB-Server:~# pwgen -cy -1 -n 10 12cahw]ie7uGnie1OoKo-uAnguu4Iu!Nhie%m2ojeHbe7Wo{w:ahEe^quaif2ulo{Ngia1ceAeToh"D7AhieS5Cho=chLu4seey<aBSi>oR.aiH6eo;l6Fie1m |