それマグで!

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

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

もう、パスワードを考えるのが面倒くさい⇛生成コマンド

パスワード考えるのが、もう面倒くさい

安全なパスワードとして、生成パターンを12文字程度で作ってたんですけど

パスワード8文字指定記号のみとか言うサイトがまだ山ほどあって発狂しそうになる。

!”#$%&’()=〜|{}_?><+*`:;,./_とかも使わせてよ!タブや空白だって文字だろ!なんで@マークをパスワードに入れたらダメなの?

おまえら、文字列を直接見る機会があるのか?文字列を直接見る機会があるから、文字列を制限するんだろ?な?

パスワードはもう自動生成にします。

パスワードを生成するコマンド、OSX 版 sf-pwdgen

sf-pwgen がベター

sf-pwgen を使うとベターなのは、次の理由です。

sf-pwgen is a command line tool which generates passwords using the SecurityFoundation framework in OS X. It runs on Mountain Lion and later.

これは、OSXのSecurityFoundation.frameworkのSFPasswordAssistantを使ってパスワードを生成するコマンドですね。

せっかくOSXなので、OSXAPIを使いましょう。

このmacOS のSecurityFoundationのFrameworkの実装をつかっているのが、sf-pwgenになります。

インストール

brew install sf-pwgen

使い方

takuya@rena:~/Desktop$ sf-pwgen -h
sf-pwgen 1.2: OS X password generator
by Anders Bergh <anders1@gmail.com>

usage: sf-pwgen [options]

Option:            Meaning:
  -a, --algorithm    Available algorithms: memorable, random
                     letters, alphanumeric, numbers.
                     The default is `memorable'.
  -c, --count        The number of passwords to generate.
  -l, --length       Desired length of the generated passwords.
  -L, --language     Generate passwords in a specified language.
                    Languages: en, de, es, fr, it, nl, pt, jp.
                     Note that this feature is broken and will
                     produce garbage, bug: rdar://14889281
  -v, --version      Print the version number and exit.
  -h, --help         Print this message.

sf-pwgenの特徴

比較的、使いやすいパスワードが出てくることが特徴。

takuya@rena:~/Desktop$ sf-pwgen  -l  12 -c 10
rouÃ68'ever
leek135.anna
pixie43*awes
mag3[rancher
Anne7[tarter
seeps70{shah
dyad419*Gill
palm768"saut
orc6/hookahs
racks36]Feds

一見して、わかりやすく、入力ミスが起きにくそうなパスワードが出てくるので使いやすい

mkpassed / pwgen

こちらは、通常に実装されたパスワード生成ツール 使い方とか

pwgen の使い方

takuya@rena:~/Desktop$ 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

mkpasswd.pl の使い方

takuya@rena:~/Desktop$ ssh s0 mkpasswd.pl -h
Usage: mkpasswd.pl [-options]
    -l # | --length=#   length of password (default = 9)
    -d # | --digits=#   min # of digits (default = 2)
    -c # | --lower=#    min # of lowercase chars (default = 2)
    -C # | --upper=#    min # of uppercase chars (default = 2)
    -s # | --special=#  min # of special chars (default = 1)
    -2 | --distribute   alternate hands
    --nodigits          alias for --digits=0
    --nolower           alias for --lower=0
    --noupper           alias for --upper=0
    --nospecial         alias for --special=0

実際に生成したパスワード候補

takuya@rena:~/Desktop$ ssh s0 'for ((i=0;i<10;i++)) ; do  mkpasswd.pl  -l 12     ; done ;'
3)jbvmAMj1tu
1pqPyvg5>nFm
J4z&awnJsf5c
3uRlrq+bzLp6
1Rll}dcox4kQ
0tcQnb2F)muk
yOmt4ivk2A,m
5sVbn%gbqD9n
yKix1?zh7oSu
sR4mm!s0aZwl

うん、sf-pwgen のほうが使いやすい文字の並びだわ。

注意 mkpasswd は linux の/etc/passwd 用だから

これは、/etc/passwd に登録できるパスワード文字列を生成するコマンドだから、WEBサイトに使うようじゃないね。

takuya@rena:~/Desktop$ ssh s0 mkpasswd -h
使い方: mkpasswd [OPTIONS]... [PASSWORD [SALT]]
PASSWORD を crypt(3) で暗号化

      -m, --method=TYPE     select method TYPE
      -5                    like --method=md5
      -S, --salt=SALT       use the specified SALT
      -R, --rounds=NUMBER   use the specified NUMBER of rounds
      -P, --password-fd=NUM read the password from file descriptor NUM
                            instead of /dev/tty
      -s, --stdin           like --password-fd=0
      -h, --help            display this help and exit
      -V, --version         output version information and exit

If PASSWORD is missing then it is asked interactively.
If no SALT is specified, a random one is generated.
If TYPE is 'help', available methods are printed.

Report bugs to <md+whois@linux.it>.

インストールは、brew から

brew install pwgen
brew install sf-pwgen

mkpasswd.pl は linuxで使う

apt install libstring-mkpasswd-perl

OSX なら CPAN 使えばいいよ。

参考資料

https://bitbucket.org/anders/sf-pwgen/

http://blog.syuhari.jp/archives/809

ランダムな初期パスワードを作るコマンド - それマグで!

更新

2020-04-22 brew install の記述が抜けてたので追記