Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Create 10 system users in batch and set random number password

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

There are many ways for linux to generate random passwords, two of which are introduced here, one is the internal system variable ($RANDOM), and the other is to use openssl.

The internal system variable ($RANDOM) can directly echo to get a set of random numbers:

# echo $RANDOM30468

Get an 8-digit random number:

# echo $RANDOM | md5sum | cut-c 1-8393c839b

Use the openssl command to get a random number:

# openssl rand-base64 8qpIpWLYS6Yk =

Get an 8-digit random number:

# openssl rand-base64 8 | cut-c 1-8GPHYu+MU

Create 10 system users in batch and set the random number password script to:

# cat useradd.sh #! / bin/bashfor I in `seq-w 10` do pass= `echo $RANDOM | md5sum | cut-c 1-8` # when using random numbers as passwords, be sure to define variables, otherwise the generated password and the last recorded password are not uniform useradd user$i & & echo $password | passwd-stdin user$i echo-e "user:user$i\ t pass:$pass" > > / tmp/user.logdone

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report