GNU/Linux >> Linux の 問題 >  >> Linux

Linux でランダムなパスワードを生成する 8 つの方法

Linux ネイティブ コマンドまたはサードパーティ ユーティリティを使用して、Linux でランダム パスワードを生成する 8 つの異なる方法を学びます。

この記事では、Linux ターミナルでランダム パスワードを生成するさまざまな方法について説明します。ネイティブの Linux コマンドを使用しているものはほとんどなく、Linux マシンに簡単にインストールできるサードパーティのツールまたはユーティリティを使用しているものもあります。ここでは、openssl のようなネイティブ コマンドを見ています。 dd、md5sumtrurandom mkpasswd、randpw、pwgen、spw、gpg、xkcdpass、diceware、revelation、keepaasx、passwordmaker などのサードパーティ ツール。

これらは実際には、パスワードとして利用できるランダムな英数字の文字列を取得する方法です。新しいユーザーにはランダムなパスワードを使用できるため、ユーザーベースがどれほど大きくても一意性が保たれます。遅滞なく、Linux でランダム パスワードを生成する 15 の異なる方法に飛び込みましょう。

mkpasswd ユーティリティを使用してパスワードを生成する

mkpasswd expect のインストールが付属しています RHEL ベースのシステムのパッケージ。 Debian ベースのシステム mkpasswd の場合 パッケージ whois に付属 . mkpasswd をインストールしようとしています パッケージはエラーになります –

パッケージ mkpasswd がありません。 RHEL システムおよび E:パッケージ mkpasswd が見つかりません Debian ベース。

上記のように親パッケージをインストールすれば、準備完了です。

mkpasswd を実行 パスワードを取得する

root@kerneltalks# mkpasswd << on RHEL
zt*hGW65c

root@kerneltalks# mkpasswd teststring << on Ubuntu
XnlrKxYOJ3vik

コマンドはシステムによって動作が異なるため、それに応じて動作します。長さなどのパラメータを制御するために使用できる多くのスイッチがあります。それらは man ページから調べることができます。

OpenSSL を使用してパスワードを生成する

OpenSSL は、ほぼすべての Linux ディストリビューションに組み込まれています。そのランダム関数を使用して、パスワードとして使用できる英数字の文字列を生成できます。

root@kerneltalks # openssl rand -base64 10
nU9LlHO5nsuUvw==

ここでは、base64 を使用しています。 base64 への引数のランダム関数と最後の桁を使用したエンコード エンコーディング。

urandom を使用してパスワードを生成

デバイスファイル /dev/urandom ランダムな文字を取得する別のソースです。 tr を使用しています 関数とトリミング出力を使用して、パスワードとして使用するランダムな文字列を取得します。

root@kerneltalks # strings /dev/urandom |tr -dc A-Za-z0-9 | head -c20; echo
UiXtr0NAOSIkqtjK4c0X

パスワードを生成する dd コマンド

/dev/urandom も使用できます ランダムな文字の文字列を取得するための dd コマンドと一緒にデバイス。

root@kerneltalks# dd if=/dev/urandom bs=1 count=15|base64 -w 0
15+0 records in
15+0 records out
15 bytes (15 B) copied, 5.5484e-05 s, 270 kB/s
QMsbe2XbrqAc2NmXp8D0

出力を base64 に渡す必要があります 人間が読めるようにエンコードします。カウント値で遊んで、目的の長さを取得できます。よりクリーンな出力を得るには、std2 を /dev/null にリダイレクトします .クリーン コマンドは –

root@kerneltalks # dd if=/dev/urandom bs=1 count=15 2>/dev/null|base64 -w 0
F8c3a4joS+a3BdPN9C++

md5sum を使用してパスワードを生成する

パスワードとして使用できるランダムな文字の配列を取得する別の方法は、MD5 チェックサムを計算することです!チェックサム値は、ランダムな文字がグループ化されたように見えますが、これをパスワードとして使用できます。コマンドを実行するたびに異なるチェックサムを取得できるように、ソースを何らかの変数として使用してください。例:date ! date コマンドは常に出力を変更します。

root@kerneltalks # date |md5sum
4d8ce5c42073c7e9ca4aeffd3d157102  -

ここで date を渡しました md5sum へのコマンド出力 チェックサムハッシュを取得します!カット コマンドを使用して、必要な長さの出力を取得できます。

pwgen を使用してパスワードを生成する

pwgen パッケージには EPEL などのリポジトリが付属しています。 pwgen 発音可能だが辞書の単語ではない、または平易な英語ではないパスワードを生成することに重点を置いています。標準の配布レポでは見つからない場合があります。パッケージをインストールして pwgen を実行します 指図。ブーム!

root@kerneltalks # pwgen
thu8Iox7 ahDeeQu8 Eexoh0ai oD8oozie ooPaeD9t meeNeiW2 Eip6ieph Ooh1tiet
cootad7O Gohci0vo wah9Thoh Ohh3Ziur Ao1thoma ojoo6aeW Oochai4v ialaiLo5
aic2OaDa iexieQu8 Aesoh4Ie Eixou9ph ShiKoh0i uThohth7 taaN3fuu Iege0aeZ
cah3zaiW Eephei0m AhTh8guo xah1Shoo uh8Iengo aifeev4E zoo4ohHa fieDei6c
aorieP7k ahna9AKe uveeX7Hi Ohji5pho AigheV7u Akee9fae aeWeiW4a tiex8Oht

端末にパスワードのリストが表示されます!他に何が欲しいですか? Ok。 pwgen まだ探検したいのね man ページで参照できる多くのカスタム オプションが付属しています。

gpg ツールを使用してパスワードを生成する

GPG は OpenPGP 暗号化および署名ツールです。ほとんどの場合、gpg ツールはプリインストールされています (少なくとも、私の RHEL7 にはあります)。しかし、そうでない場合は gpg を探すことができます または gpg2 パッケージ化してインストールしてください。

以下のコマンドを使用して、gpg ツールからパスワードを生成します。

root@kerneltalks # gpg --gen-random --armor 1 12
mL8i+PKZ3IuN6a7a

ここでは、generate random byte sequence スイッチ (--gen-random) を渡しています。 ) 品質 1 (最初の引数) でカウント 12 (2 番目の引数)。スイッチ --armor 出力が base64 であることを保証します

xkcdpass を使用してパスワードを生成する

有名なギーク ユーモアの Web サイト xkcd は、覚えやすいが複雑なパスワードに関する非常に興味深い投稿を公開しました。ここで見ることができます。だから xkcdpass ツールはこの投稿からインスピレーションを得て、その仕事をしました!これは python パッケージであり、python の公式 Web サイト (こちら) で入手できます

すべてのインストールと使用手順は、そのページに記載されています。参考までに、私のテスト RHEL サーバーからのインストール手順と出力を次に示します。

root@kerneltalks # wget https://pypi.python.org/packages/b4/d7/3253bd2964390e034cf0bba227db96d94de361454530dc056d8c1c096abc/xkcdpass-1.14.3.tar.gz#md5=5f15d52f1d36207b07391f7a25c7965f
--2018-01-23 19:09:17--  https://pypi.python.org/packages/b4/d7/3253bd2964390e034cf0bba227db96d94de361454530dc056d8c1c096abc/xkcdpass-1.14.3.tar.gz
Resolving pypi.python.org (pypi.python.org)... 151.101.32.223, 2a04:4e42:8::223
Connecting to pypi.python.org (pypi.python.org)|151.101.32.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 871848 (851K) [binary/octet-stream]
Saving to: ‘xkcdpass-1.14.3.tar.gz’

100%[==============================================================================================================================>] 871,848     --.-K/s   in 0.01s

2018-01-23 19:09:17 (63.9 MB/s) - ‘xkcdpass-1.14.3.tar.gz’ saved [871848/871848]


root@kerneltalks # tar -xvf xkcdpass-1.14.3.tar.gz
xkcdpass-1.14.3/
xkcdpass-1.14.3/examples/
xkcdpass-1.14.3/examples/example_import.py
xkcdpass-1.14.3/examples/example_json.py
xkcdpass-1.14.3/examples/example_postprocess.py
xkcdpass-1.14.3/LICENSE.BSD
xkcdpass-1.14.3/MANIFEST.in
xkcdpass-1.14.3/PKG-INFO
xkcdpass-1.14.3/README.rst
xkcdpass-1.14.3/setup.cfg
xkcdpass-1.14.3/setup.py
xkcdpass-1.14.3/tests/
xkcdpass-1.14.3/tests/test_list.txt
xkcdpass-1.14.3/tests/test_xkcdpass.py
xkcdpass-1.14.3/tests/__init__.py
xkcdpass-1.14.3/xkcdpass/
xkcdpass-1.14.3/xkcdpass/static/
xkcdpass-1.14.3/xkcdpass/static/eff-long
xkcdpass-1.14.3/xkcdpass/static/eff-short
xkcdpass-1.14.3/xkcdpass/static/eff-special
xkcdpass-1.14.3/xkcdpass/static/fin-kotus
xkcdpass-1.14.3/xkcdpass/static/ita-wiki
xkcdpass-1.14.3/xkcdpass/static/legacy
xkcdpass-1.14.3/xkcdpass/static/spa-mich
xkcdpass-1.14.3/xkcdpass/xkcd_password.py
xkcdpass-1.14.3/xkcdpass/__init__.py
xkcdpass-1.14.3/xkcdpass.1
xkcdpass-1.14.3/xkcdpass.egg-info/
xkcdpass-1.14.3/xkcdpass.egg-info/dependency_links.txt
xkcdpass-1.14.3/xkcdpass.egg-info/entry_points.txt
xkcdpass-1.14.3/xkcdpass.egg-info/not-zip-safe
xkcdpass-1.14.3/xkcdpass.egg-info/PKG-INFO
xkcdpass-1.14.3/xkcdpass.egg-info/SOURCES.txt
xkcdpass-1.14.3/xkcdpass.egg-info/top_level.txt


root@kerneltalks # cd xkcdpass-1.14.3

root@kerneltalks # python setup.py install
running install
running bdist_egg
running egg_info
writing xkcdpass.egg-info/PKG-INFO
writing top-level names to xkcdpass.egg-info/top_level.txt
writing dependency_links to xkcdpass.egg-info/dependency_links.txt
writing entry points to xkcdpass.egg-info/entry_points.txt
reading manifest file 'xkcdpass.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'xkcdpass.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/xkcdpass
copying xkcdpass/xkcd_password.py -> build/lib/xkcdpass
copying xkcdpass/__init__.py -> build/lib/xkcdpass
creating build/lib/xkcdpass/static
copying xkcdpass/static/eff-long -> build/lib/xkcdpass/static
copying xkcdpass/static/eff-short -> build/lib/xkcdpass/static
copying xkcdpass/static/eff-special -> build/lib/xkcdpass/static
copying xkcdpass/static/fin-kotus -> build/lib/xkcdpass/static
copying xkcdpass/static/ita-wiki -> build/lib/xkcdpass/static
copying xkcdpass/static/legacy -> build/lib/xkcdpass/static
copying xkcdpass/static/spa-mich -> build/lib/xkcdpass/static
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/xkcdpass
copying build/lib/xkcdpass/xkcd_password.py -> build/bdist.linux-x86_64/egg/xkcdpass
copying build/lib/xkcdpass/__init__.py -> build/bdist.linux-x86_64/egg/xkcdpass
creating build/bdist.linux-x86_64/egg/xkcdpass/static
copying build/lib/xkcdpass/static/eff-long -> build/bdist.linux-x86_64/egg/xkcdpass/static
copying build/lib/xkcdpass/static/eff-short -> build/bdist.linux-x86_64/egg/xkcdpass/static
copying build/lib/xkcdpass/static/eff-special -> build/bdist.linux-x86_64/egg/xkcdpass/static
copying build/lib/xkcdpass/static/fin-kotus -> build/bdist.linux-x86_64/egg/xkcdpass/static
copying build/lib/xkcdpass/static/ita-wiki -> build/bdist.linux-x86_64/egg/xkcdpass/static
copying build/lib/xkcdpass/static/legacy -> build/bdist.linux-x86_64/egg/xkcdpass/static
copying build/lib/xkcdpass/static/spa-mich -> build/bdist.linux-x86_64/egg/xkcdpass/static
byte-compiling build/bdist.linux-x86_64/egg/xkcdpass/xkcd_password.py to xkcd_password.pyc
byte-compiling build/bdist.linux-x86_64/egg/xkcdpass/__init__.py to __init__.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying xkcdpass.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xkcdpass.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xkcdpass.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xkcdpass.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xkcdpass.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xkcdpass.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
creating dist
creating 'dist/xkcdpass-1.14.3-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing xkcdpass-1.14.3-py2.7.egg
creating /usr/lib/python2.7/site-packages/xkcdpass-1.14.3-py2.7.egg
Extracting xkcdpass-1.14.3-py2.7.egg to /usr/lib/python2.7/site-packages
Adding xkcdpass 1.14.3 to easy-install.pth file
Installing xkcdpass script to /usr/bin

Installed /usr/lib/python2.7/site-packages/xkcdpass-1.14.3-py2.7.egg
Processing dependencies for xkcdpass==1.14.3
Finished processing dependencies for xkcdpass==1.14.3

現在 xkcdpass を実行中 コマンドは、以下のような辞書の単語のランダムなセットを提供します –

root@kerneltalks # xkcdpass
broadside unpadded osmosis statistic cosmetics lugged

これらの単語を md5sum などの他のコマンドへの入力として使用できます (以下のように) ランダムなパスワードを取得するか、各単語の N 番目の文字を使用してパスワードを作成することもできます!

root@kerneltalks # xkcdpass |md5sum
45f2ec9b3ca980c7afbd100268c74819  -

root@kerneltalks # xkcdpass |md5sum
ad79546e8350744845c001d8836f2ff2  -

または、これらすべての単語を組み合わせて、ユーザーにとって覚えやすく、コンピューター プログラムを使用して解読するのが非常に困難な長いパスワードとして使用することもできます。

Diceware、KeePassX、Revelation、Linux 用の PasswordMaker などの強力なランダム パスワードを作成できるツールがあります。


Linux
  1. Linuxでバイナリファイルを分析する10の方法

  2. Linuxで強力な事前共有キー(PSK)を生成する4つの方法

  3. Linuxでランダムパスワードを生成/暗号化/復号化する方法

  1. Linuxでアカウントのパスワードを管理する方法

  2. Linuxでランダムパスワードを生成する10の方法

  3. Linuxでユーザーを一覧表示する3つの方法

  1. Linuxでビデオゲームをプレイする3つの方法

  2. KaliLinuxのデフォルトパスワード

  3. / dev/randomを使用してLinuxでランダムパスワードを生成する方法