Home  >  Article  >  System Tutorial  >  Four great tools for generating strong passwords under Linux

Four great tools for generating strong passwords under Linux

王林
王林forward
2024-02-13 15:27:031012browse

Security is a big topic, and it is very important to set a strong password for the server. You may be wondering what a strong password actually looks like? How can you generate a password like that? Don’t worry. Below we will introduce 4 simple methods for you to generate a strong password in Linux

1. Use OpenSSL to generate a strong password in Linux

Use openssl in all Unix-like distributions, Solaris, Mac OS X and Windows

To generate a random password using OpenSSL, open a terminal and run the following command:

openssl rand -base64

The "-base64" parameter above will ensure that the generated password can be typed out by the keyboard.

Output sample:

wXCHXlxuhrFrFMQLqik
Four great tools for generating strong passwords under Linux

The above command will generate a random, strong password of 14 characters in length. We strongly recommend that you generate a 14-character password. Of course you can use OpenSSL to generate passwords of any length.

For more information, you can refer to the online manual:

man openssl
Four great tools for generating strong passwords under Linux

2. Use Pwgen to generate a strong password in Linux

pwgen is a simple but very useful command line tool that can generate a random and strong password in a short time. It designs secure passwords that people can remember more easily. It is available on most Unix-like systems.

To install pwgen on DEB-based systems please run:

sudo apt-get install pwgen

On RPM-based systems, run:

yum  install pwgen

On Arch-based systems, run:

sudo pacman -S pwgen

After pwgen is installed, you can use the following command to generate a random, strong password of 14 characters in length:

pwgen 14 1

Output sample:

Choo4aicozai3a
Four great tools for generating strong passwords under Linux

The above command will generate a 14-character long password. If you want to generate two different 14-character long passwords, you can run:

pwgen 14  2
xee7seerez6Kau Aeshu0geveeji8

If you want to generate 100 (although it may not be necessary to generate that many) different 14 character long passwords, you can run:

pwgen 14

Output sample:

pwgen 14 100

Output sample:

kaeNg3EiVei4ei Oo0iehiJaix5Ae aenuv2eree2Quo iaT7zahH1eN2Aj Bie2owaiFahsie
gaan9zu5Xeh5ah ahGeeth8ea5ooh Ir0ueda5poogh5 uo0ohqu2ufaiX2 Mei0pee6Og3zae
Oofeiceer8Aipu sheew3aeReidir Dee4Heib2eim2o eig6jar8giPhae Zahde9nae1Niew
quatol5Oi3Bah2 quue4eebaiNgaa oGoahieSh5oL4m aequeeQue2piti laige5seePhugo
iiGo9Uthee4ros WievaiQu2xech6 shaeve0maaK3ae ool8Pai2eighis EPheiRiet1ohci
ZieX9outhoht8N Uh1UoPhah2Thee reaGhohZae5idi oiG4ooshiyi5in keePh1ohshei8y
aim5Eevah2thah Xaej8tha5eisho IeGie1Anaalaev gaoY3ohthooh3x chaebeesahTh8e
soh7oosieY5eiD ahmoh6Ihii6que Shoowoo5dahbah ieW0aiChubee7I Caet6aikai6aex
coo1du2Re9aika Ohnei5Egoh7leV aiyie6Ahdeipho EiV0aeToeth1da iNgaesu4eeyu0S
Eeb1suoV3naera railai2Vaina8u xu3OhVee1reeyu Og0eavae3oohoh audahneihaeK8a
foo6iechi5Eira oXeixoh6EwuboD we1eiDahNgoh9s ko1Eeju1iedu1z aeP7achiisohr7
phang5caeGei5j ait4Shuo5Aitai no4eis9Tohd8oh Quiet6oTaaQuei Dei2pu2NaefeCa
Shiim9quiuy0ku yiewooph3thieL thu8Aphai1ieDa Phahnahch1Aam1 oocex7Yaith8oo
eraiGaech5ahNg neixa3malif5Ya Eux7chah8ahXix eex1lahXae4Mei uGhahzonu6airu
yah8uWahn3jeiW Yi4ye4Choongie io1Vo3aiQuahpi rie4Rucheet6ae Dohbieyaeleis5
xi1Zaushohbei7 jeeb9EiSiech0u eewo0Oow7ielie aiquooZamah5th kouj7Jaivohx9o
biyeeshesaDi9e she9ooj3zuw6Ah Eit7dei1Yei5la xohN0aeSheipaa Eeg9Phob6neema
eengoneo4saeL4 aeghi4feephu6W eiWash2Vie1mee chieceish5ioPe ool4Hongo7ef1o
jahBe1pui9thou eeV2choohoa4ee Ohmae0eef4ic8I Eet0deiyohdiew Ke9ue5thohzei3
aiyoxeiva8Maih gieRahgh8anahM ve2ath9Eyi5iet quohg6ok3Ahgee theingaech5Nef

If you want to include at least 1 number in your password, you can run:

pwgen  14  1 -n  1

Output sample:

xoiFush3ceiPhe

In addition, the pwgen command also has some very practical options:

-c 或 --capitalize 在密码中包含至少一个大写字母
-A 或 --no-capitalize 在密码中不包含大写字母
-n 或 --numerals 在密码中包含至少一个数字
-0 或 --no-numerals 在密码中不包含数字
-y 或 --symbols 在密码中包含至少一个特殊字符
-s 或 --secure 生成完全随机的密码
-B 或 --ambiguous 在密码中不包含难于区分的字母,如 0 和 o、1 和 l
-h 或 --help 输出帮助信息
-H 或 --sha1=path/to/file[#seed] 使用某个给定文件的 sha1 哈希值来作为随机数的生成种子
-C 按列输出生成好的密码
-1 不按列输出生成好的密码
-v 或 --no-vowels 不使用任何元音字母,以防止生成下流的词语 ```

For more information, please consult its online manual:

man pwgen

3. Use GPG to generate a strong password in Linux

GPG (GnuPG or GNU Privacy Guard) is a free and open source command-line program that can be used to replace Symantec's PGP encryption software. It is available on Unix-like operating systems, Microsoft Windows, and Android.

To use PGP to generate a strong 14-character password, run the following command in a terminal:

 gpg --gen-random --armor 1 14

Output sample:

DkmsrUy3klzzbIbavx8=

The above command will generate a secure, random, strong and base64-encoded password.

4. Use Perl to generate a strong password in Linux

Perl is available in the default software repository of most Linux distributions, and you can install it using the corresponding package manager.

For example, on a DEB-based system, you can run the following command to install Perl:

sudo apt-get install perl

To install Perl on an RPM-based system, run:

sudo yum install perl

On Arch-based systems, run:

sudo pacman -S perl

Once Perl is installed, create a file using the following command:

vi password.pl

Then add the following content to this file:

#!/usr/bin/perl
my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..8;
print "$randpassword\n"
Four great tools for generating strong passwords under Linux

Save and close the file.

Next, switch to the location where you just saved the file and run the following command:

perl password.pl

Replace "password.pl" in the above command with your own defined file name.

Output sample:

3V4CJJnYd
Four great tools for generating strong passwords under Linux

ps:安全是一个大话题,对于生成的密码,你必须记住它,可以把它保存到安全的地方。不要好不容易设置一个强密码然后用便利贴贴在屏幕上面。

The above is the detailed content of Four great tools for generating strong passwords under Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete