Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to generate Random password in Linux

Shulou Source: shulou.com Published: 2022-06-01 14:52:17 10月04日 Update

I believe many inexperienced people don't know how to generate random passwords in Linux. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Use the mkpasswd utility to generate a password

Mkpasswd is installed with the expect package on RHEL-based systems. On Debian-based systems, mkpasswd is in the package whois. Installing the mkpasswd package directly will result in an error:

RHEL system: the package mkpasswd is not available.

Debian system: error: unable to locate package mkpasswd.

So install their parent package as described above, and there will be no problem.

Run mkpasswd to get the password

Root@kerneltalks# mkpasswd] 871848 -.-- K root@kerneltalks# mkpasswd s in 0.01s 2018-01-23 19:09:17 (63.9 MB/s)-'xkcdpass-1.14.3.tar.gz' saved [871848Comp871848] root@kerneltalks# tar-xvf xkcdpass-1.14.3.tar.gzxkcdpass-1.14.3/xkcdpass-1.14.3/examples/xkcdpass-1.14.3/examples/example_import.pyxkcdpass-1.14.3/examples / example_json.pyxkcdpass-1.14.3/examples/example_postprocess.pyxkcdpass-1.14.3/LICENSE.BSDxkcdpass-1.14.3/MANIFEST.inxkcdpass-1.14.3/PKG-INFOxkcdpass-1.14.3/README.rstxkcdpass-1.14.3/setup.cfgxkcdpass-1.14.3/setup.pyxkcdpass-1.14.3/tests/xkcdpass-1.14.3/tests/test_list.txtxkcdpass-1.14.3/tests/test_xkcdpass.pyxkcdpass-1 .14.3 / tests/__init__.pyxkcdpass-1.14.3/xkcdpass/xkcdpass-1.14.3/xkcdpass/static/xkcdpass-1.14.3/xkcdpass/static/eff-longxkcdpass-1.14.3/xkcdpass/static/eff-shortxkcdpass-1.14.3/xkcdpass/static/eff-specialxkcdpass-1.14.3/xkcdpass/static/fin-kotusxkcdpass-1.14.3/xkcdpass/static/ita-wikixkcdpass-1.14.3/xkcdpass/static/legacyxkcdpass-1 .14.3 / xkcdpass/static/spa-michxkcdpass-1.14.3/xkcdpass/xkcd_password.pyxkcdpass-1.14.3/xkcdpass/__init__.pyxkcdpass-1.14.3/xkcdpass.1xkcdpass-1.14.3/xkcdpass.egg-info/xkcdpass-1.14.3/xkcdpass.egg-info/dependency_links.txtxkcdpass-1.14.3/xkcdpass.egg-info/entry_points.txtxkcdpass-1.14.3/xkcdpass.egg-info/not-zip-safexkcdpass -1.14.3/xkcdpass.egg-info/PKG-INFOxkcdpass-1.14.3/xkcdpass.egg-info/SOURCES.txtxkcdpass-1.14.3/xkcdpass.egg-info/top_level.txt root@kerneltalks # cd xkcdpass-1.14.3 root@kerneltalks # python setup.py installrunning installrunning bdist_eggrunning egg_infowriting xkcdpass.egg-info/PKG-INFOwriting top-level names to xkcdpass.egg-info/top_level.txtwriting dependency_links to xkcdpass.egg-info/dependency_links.txtwriting entry points To xkcdpass.egg-info/entry_points.txtreading 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/eggrunning install_librunning build_pycreating buildcreating build/libcreating build/lib/xkcdpasscopying xkcdpass/xkcd_password.py-> build/lib/xkcdpasscopying xkcdpass/__init__.py-> build/lib/xkcdpasscreating build/lib/xkcdpass/staticcopying xkcdpass/static/eff- Long-> build/lib/xkcdpass/staticcopying xkcdpass/static/eff-short-> build/lib/xkcdpass/staticcopying xkcdpass/static/eff-special-> build/lib/xkcdpass/staticcopying xkcdpass/static/fin-kotus-> build/lib/xkcdpass/staticcopying xkcdpass/static/ita-wiki-> build/lib/xkcdpass/staticcopying xkcdpass/static/legacy-> build/lib/xkcdpass/staticcopying xkcdpass/static/spa-mich-> build/lib/xkcdpass/staticcreating build/bdist.linux-x86_64creating build/bdist.linux-x86 _ 64/eggcreating build/bdist.linux-x86_64/egg/xkcdpasscopying build/lib/xkcdpass/xkcd_password.py-> build/bdist.linux-x86_64/egg/xkcdpasscopying build/lib/xkcdpass/__init__.py-> build/bdist.linux-x86_64/egg/xkcdpasscreating build/bdist.linux-x86_64/egg/xkcdpass/staticcopying build/lib/xkcdpass/static/eff-long-> build/bdist.linux-x86_64/egg/xkcdpass/staticcopying build/lib/xkcdpass/ Static/eff-short-> build/bdist.linux-x86_64/egg/xkcdpass/staticcopying build/lib/xkcdpass/static/eff-special-> build/bdist.linux-x86_64/egg/xkcdpass/staticcopying build/lib/xkcdpass/static/fin-kotus-> build/bdist.linux-x86_64/egg/xkcdpass/staticcopying build/lib/xkcdpass/static/ita-wiki-> build/bdist.linux-x86_64/egg/xkcdpass/staticcopying build/lib/xkcdpass/static/legacy-> build/bdist .linux-x86_64/egg/xkcdpass/staticcopying build/lib/xkcdpass/static/spa-mich-> build/bdist.linux-x86_64/egg/xkcdpass/staticbyte-compiling build/bdist.linux-x86_64/egg/xkcdpass/xkcd_password.py to xkcd_password.pycbyte-compiling build/bdist.linux-x86_64/egg/xkcdpass/__init__.py to _ _ init__.pyccreating build/bdist.linux-x86_64/egg/EGG-INFOcopying xkcdpass.egg-info/PKG -INFO-> build/bdist.linux-x86_64/egg/EGG-INFOcopying xkcdpass.egg-info/SOURCES.txt-> build/bdist.linux-x86_64/egg/EGG-INFOcopying xkcdpass.egg-info/dependency_links.txt-> build/bdist.linux-x86_64/egg/EGG-INFOcopying xkcdpass.egg-info/entry_points.txt-> build/bdist.linux-x86_64/egg/EGG-INFOcopying xkcdpass.egg-info/not-zip-safe-> build/bdist.linux- X86_64/egg/EGG-INFOcopying xkcdpass.egg-info/top_level.txt-> build/bdist.linux-x86_64/egg/EGG-INFOcreating distcreating 'dist/xkcdpass-1.14.3-py2.7.egg' and adding' build/bdist.linux-x86_64/egg' to itremoving 'build/bdist.linux-x86_64/egg' (and everything under it) Processing xkcdpass-1.14.3-py2.7.eggcreating / usr/lib/python2.7/site-packages/xkcdpass -1.14.3-py2.7.eggExtracting xkcdpass-1.14.3-py2.7.egg to / usr/lib/python2.7/site-packagesAdding xkcdpass 1.14.3 to easy-install.pth fileInstalling xkcdpass script to / usr/bin Installed / usr/lib/python2.7/site-packages/xkcdpass-1.14.3-py2.7.eggProcessing dependencies for xkcdpass==1.14.3Finished processing dependencies for xkcdpass==1.14.3

Now run the xkcdpass command and you will be randomly given several dictionary words like the following:

Root@kerneltalks # xkcdpassbroadside unpadded osmosis statistic cosmetics lugged

You can use these words as other commands, such as md5sum, to get random passwords (like the following), and you can even use the nth letter of each word to generate your password!

Root@kerneltalks # xkcdpass | md5sum45f2ec9b3ca980c7afbd100268c74819-root@kerneltalks # xkcdpass | md5sumad79546e8350744845c001d8836f2ff2-after reading the above, have you mastered the method of generating random passwords in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Password generation command software software package output character string tool system parameter method length run word standard code error problem difference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Xiaomi OPPO Reno vpn macOS