in

How to Generate, Encrypt, Decrypt Random Passwords in Linux

Strong Random Password Generator
Reading Time: 5 minutes

Hello, In this article we are going to explain how to generate, encrypt & decrypt random passwords in Linux. We added some most powerful Linux commands for generating random passwords. By using these commands you can able to encrypt and decrypt the random passwords easily. These methods will help you to generate a strong password.

Common Facts For Generating Random Passwords:

  • Password length must be in more than 14 characters
  • It includes Small letter & Capital letters.
  • It includes numeric characters.
  • It includes some random symbols and characters.

Security is one of the most important matter nowadays. Hackers are getting more stronger than previous and so we need to take proper precautionary. It is very easy to generate the most powerful password using the following commands. Linux is very good at this and so these passwords are generated by using the machine based language generator.

Generate Random Password using with OpenSSL:

The below codes will generate OpenSSL using rand function and it will generate the random passwords.

openssl rand -base64 14

How to use? Copy the above code and paste in terminal

Generate Random Strong password using gpg:

You can use the gpg tool to generate random passwords otherwise you can use the following commands to generate random strong passwords.

gpg –gen-random –armor 1 14

How to use? Copy the above code and paste in terminal

Generate Random Password using Gen Password:

When you need to generate a random password then we suggest you use the “genpasswd” command and the random password will be generated in the terminal.

genpasswd() {
strings /dev/urandom | grep -o ‘[[:alnum:]]’ | head -n 14 | tr -d ‘\n’; echo
}

Check this too  10 Interesting Usages of "!" Operator in Linux Commands

How to use? Copy the above code and paste in terminal

Generate Password using PWGEN:

For using these commands, you just need to install APT or Yum in your pc. The simple command used for generating passwords is “pwgen“.

pwgen 10 1

How to use? Copy the above code and paste in terminal

pwgen 10 1
pwgen 10 1 command
pwgen 50

How to use? Copy the above code and paste in terminal

The above command will generate a 50 random character password. This command will generate a random password.

pwgen 50
pwgen 50 command

Generate Password using MakePassword:

makepasswd

How to use? Copy the above code and paste in terminal

This is similar to “rand” and it generates a random password with random characters.

makepasswd command
makepasswd commands
makepasswd –char 100

How to use? Copy the above code and paste in terminal

This command will generate a random password contains 100 random characters.

makepasswd --char 100 command
makepasswd –char 100 commands
makepasswd –char 20 –count 5

How to use? Copy the above code and paste in terminal

makepasswd --char 10 --count 5
makepasswd –char 10 –count 5 command

How to encrypt the password in Linux:

The Linux has the inbuilt password encrypted. It will be very easy to generate an encrypted password. For this, you just need to install “Salt“. Salt is a random data which serves as an additional input to one-way function in order to protect password against the dictionary attack.

The below command will generate a random encrypted password.

mkpasswd

How to use? Copy the above code and paste in terminal

mkpasswd command
mkpasswd command

Now let us define the salt. It will output the same result every-time. Note you can input anything of your choice as salt.

mkpasswd tecrobust -s tt

Check this too  Wget Command in Linux: Wget Command Syntax, Options & Examples!

How to use? Copy the above code and paste in terminal

mkpasswd -s tt
mkpasswd -s tt command

Encrypt a strong password using aes-256-cbc:

Here we explained this command using the aes-256-cbc for the following string “Tecrobust is the best” using a password “Tecrobust”

Password encrypted using openssl
Password encrypted using openssl

Here the echoed input has been encrypted using Encoding with Cipher (enc), which uses aes-256-cbc encryption algorithm finally with salt it is encrypted using the password (tecrobust).

Decrypt a Random Password using Linux:

Decrypt the above string using openssl command using the -aes-256-cbc decryption. The encrypted password has been generated using the above Linux command.

Decrypt Password
Decrypt Password

Okay, friends. You reached the conclusion here. The above methods are the most commonly using methods to generate a random password using Linux commands. If you have any queries related to this and then feel free to comment on us.

  • Article Length
  • Article Explanation
  • Image Explanation
  • Command's Clarity
4.8

Summary

The best methods to generate Random Strong password using Linux commands are posted here.

Written by Rachel

I'm Rachel, From Arizona. Am playing the "Content Management" Role in Tec Robust. I started working in TR from Jan 2019. Big Marvel Fan.

Contact me:
tecrobust [@] gmail.com
Sub: Message to Rachel

Comments

Leave a Reply

Loading…

0

Comments

0 comments

Cron Jobs Linux

10+ CronJob Scheduling Task In Linux Using Terminal

How to handle filenames with special characters

How to Handle Filenames Contains a Special Symbols, Characters and Spaces?