[macOS] パスワード用のランダム文字列生成コマンド pwgen

Tadashi Shigeoka ·  Thu, March 7, 2019

macOS でパスワード用のランダム文字列を生成するコマンド pwgen をご紹介します。

pwgen インストール

brew install pwgen

pwgen の使い方

pwgen

オプションなしで実行すると以下のように 8文字のパスワード候補が出力されます。

$ pwgen
quuSah9r eey6eeL8 Oevuegh4 olinoo7M jej1Go0I Mee1Thoo ae0heePi heeth6Uf
Jaelu5ee tath5ooZ mou9eeCh Tee2jee3 epohT8yo queeDe4P sahm0Vi7 Wathair1
Vaekie4i aiNoo9ai aequ4ieK gooP8faL Aegaiqu3 oLie9axa Keir9nah li3hai8M
oLief2re va2Haig3 lo1Thaef Quee7eek waiB3De4 Uich6shi Sha7aeM1 ioha5Gox
te0xieNg Na4iesh0 aepaiT3I wahK7nah Ija8ruu7 Zi4aesei lo1EiCah pooCh0ci
suxiev3U shu5Ose8 looThoe9 xuNg3Io4 ee7Aedoh aeph2Qua Za4no5uk oa6Euchu
chu5EiXi il6iez2H ubaeWoi0 PhaeTie2 cai5aeN9 eer6eiZi Ei1eeHah IeV8ohga
OoviDov0 eeDah5oo quiu1EiL Uuquoog0 yae1ALah Mie6jeeg aeZie8ho Mishi2oh
uqueB7ah Ieghie5h ueS2shae Shei9aeb ahR8quai Au7dee1U xea8Aw5k ailee4Re
Cee5iupe ahqu4Ye5 Chei8eiw theez8Qu xoi1zeiH Ohfaem0O Quaeth3o Leif0lin
Phiebak1 buDe8Mae veshe5Ia Aipae3wo Uye1gahl AuPhae6w leF9xaep Piek1yet
yiPee7ch Sha9AiPa Aenoo8wo ahCohch8 Weivoo9d ooyaev0J ahl3EiNu ru2Chae8
aeP7theH Iniech2h EeTu0wee ohboNoK9 ohd2Ob2i oL8Aiphu wochoZ4V eeL5aivi
oochie5D roh5po0I Waekaa3c aih1ioGh ix0Ahcho neiGee5k ooTepho9 GiNa3Ach
eir5Eequ iel1ohK3 Nuk9Zae3 uc1FouTh aex3Xago Geeboi8l ooT5xioc uc3eeCha
Aeyu6oop Zeizo7be feir3Yei ZooZahP3 ma2geiPi Seingo6K ooc9Yaip ahR1hei9
auLam9to abah9Ex9 gio1ohL0 Pau4Jieb aeYie6Th jah0yieC ohDoh1vu Oop4phie
EiM8ooc3 lahd3oW6 Gi3AeHah Ij1sheeT deem0eXe aih4Ieyi ouVohng1 eix6Aith
heij7Lau ohCoZ4Oh wooPoo1f paiTh3Qu Aig4ieyo Pohgoh1z bamiew7C eeW2ahjo
ahje1ieZ ohG4GahX hi3Eepe1 Ji3Foo8A Thue5ev0 baN4eihi Azoo8aPh ako4ouCh

pwgen オススメの使い方

-s -y オプションを付けて実行するのがオススメの使い方です。

  • -s 「完全にランダムにする」オプション
  • -y 「記号文字を含める」オプション
$ pwgen -sy 32 1 
k&opIUQ2/

pwgen --help

$ pwgen --help
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
  -r  or --remove-chars=
  Remove characters from the set of characters to generate passwords
  -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

以上、pwgen コマンドを使ってパスワードをランダム文字列で生成したい、現場からお送りしました。

参考情報