Have the good day
Have the good day

批量生成随机密码

 

批量生成随机密码

 

生成的密码,可以用在各个地方

批量生成,对于 “应用系统管理员” 尤其有用,给用户初始化账号、重置密码……等时候

 


# 生成一个8位Base64字符的密码
openssl rand -base64 6

# 批量生成8位Base64字符的密码
for i in {1..100}
  do
    openssl rand -base64 6 >>pw.txt
  done

openssl生成的密码有一个缺点,就是没法排除 “象形字符”

使用 openssl 批量生成随机 MAC

 

使用 openssl 批量生成随机 MAC

 

网络管理中有时用来占用 DHCP 池,占用 ARP 记录……等用途。所以前面一段设成固定的,方便识别。

 


# 格式1:AABB-CCDD-EEFF
for i in {1..256}
  do
    openssl rand -hex 4 | sed 's/^/abcd/; s/\(....\)/\1-/g; s/.$//'   >>mac.txt
  done
  
#注释:
#	openssl rand -hex 4 | sed 's/^/abcd/; s/\(....\)/\1-/g; s/.$//'
#	生成4个字节的16进制字符
#								在行首插入“abcd”
#											每隔4个字符插入一个“-”
#															删除行末最后一个字符


# 格式2:AA:BB:CC:DD:EE:FF
for i in {1..256}
  do
    openssl rand -hex 4 | sed 's/^/abcd/; s/\(..\)/\1:/g; s/.$//'   >>mac.txt
  done

# 格式3:AABBCCDDEEFF
for i in {1..256}
  do
    openssl rand -hex 4 | sed 's/^/abcd/'   >>mac.txt
  done

注意:前面插 “abcd” ,在有的网络设备,及 windows 上,会被识别位非法MAC