それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

ランダムな初期パスワードを作るコマンド

ランダムな初期パスワードを生成出来ると便利ですよね。そういうのは先人の知恵にあります。

mkpasswd コマンド

takuya@host:~$ mkpasswd
"lxN2ujZ8

便利です。 ubuntu/debian の場合は、コマンド名が、/usr/bin/mkpasswd.plになります。

生成されるパスワードのパターン

-l
パスワード文字列の長さ
-s
含まれる記号の数(0指定で記号なし)
-c
含まれる小文字の数
-C
含まれる大文字の数
-d
含まれる数字の数

生成されるパスワードの例、記号なし、大文字なし

大文字小文字を見間違えると鬱陶しいので、小文字だけに限定する。ただし文字列は16文字にする。

takuya@hot:~$ mkpasswd -s 0 -C 0 -l 16
cwqzwz4jjeiy8mle

注意Debianの場合

mkpasswd.pl という名前です!!

sudo aptitude install libstring-mkpasswd-perl

2018-12-27 追記

debian ubuntu の場合を更に追記

参考資料

http://d.hatena.ne.jp/mkires/20080702/1215006856

man mkpasswd.pl

      -l # | --length=#
           The total length of the password.  The default is 9.

       -d # | --digits=#
           The minimum number of digits that will appear in the final password.  The default is 2.

       -c # | --lower=#
           The minimum number of lower-case characters that will appear in the final password.  The default is 2.

       -C # | --upper=#
           The minimum number of upper-case characters that will appear in the final password.  The default is 2.

       -s # | --special=#
           The minimum number of non-alphanumeric characters that will appear in the final password.  The default is
           1.

       -2 | --distribute
           If specified, password characters will be distributed between the left- and right-hand sides of the
           keyboard.  This makes it more difficult for an onlooker to see the password as it is typed.

       --nodigits | --no-digits
           Alias for --digits=0.