Linux generate random Password/modify password

Source: Internet
Author: User
Tags base64 openssl

Linux generates random password methods:

Strings/dev/urandom | Grep-o ' [[: Alnum:]] ' | Head-n 30 | Tr-d ' n '; Echo

Linux Modify Password Method:

passwd Root

Then enter the new password two times

Root can be replaced by the user who needs to be modified

We have other options besides the random cipher generated above.

1. Using the MKPASSWD command:

Using the MKPASSWD command, you need to install the expect module in advance, taking CentOS as an example:

Yum-y Install expect

After installation, directly run MKPASSWD, you can generate a random password. And the command also has parameters, such as setting the minimum length of the generated random password, and so on, to see Help.

2. Using the Passwdgen command:

In line with the MKPASSWD, the Passwdgen module must be installed beforehand:

Yum-y Install Passwdgen

After installation, directly run Passwdgen, you can get a random password, the same Passwdgen command also has parameters, you can refer to help.

Add some generate random password command

Here are 10 instances of generating random passwords

1.sha+date+base64, Password length 32

Date +%s | Sha256sum | Base64 | Head-c 32; Echo

2. Use Urandom, filter out other symbols, leaving only letters and numbers, password length 32

</dev/urandom TR-DC _a-z-a-z-0-9 | Head-c${1:-32};echo;

3. Random functions using OpenSSL

OpenSSL Rand-base64 32

Another use of 4.urandom, URANDOM+TR

TR-CD ' [: alnum:] ' </dev/urandom | fold-w30 | Head-n1

5. Use Urandom plus character function

Strings/dev/urandom | Grep-o ': alnum: ' | Head-n 30 | Tr-d ' n '; Echo

The simplest use of 6.urandom

</dev/urandom TR-DC _a-z-a-z-0-9 | Head-c6

Another use of 7.urandom, URANDOM+DD

DD if=/dev/urandom Bs=1 count=32 2>/dev/null | Base64-w 0 | Rev | Cut-b 2-| Rev

8. If you often use a single hand to enter a password, you can refer to the following methods to generate "left-handed password"

/dev/urandom tr-dc ' 12345!@#$%QWERTQWERTASDFGASDFGZXCVBZXCVB ' | Head-c8; echo ""

9. Use RANDPW plus urandom

RANDPW () {</dev/urandom tr-dc _a-z-a-z-0-9 | Head-c${1:-16};echo;}

10. Finally, the most concise

Date | Md5sum

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.