本文介绍了一个由 John Kristoff 启发的 Bash 脚本,用于生成随机密码,可设置密码长度和生成数量,还提供了下载链接及作者的社交媒体信息。
🎯该 Bash 脚本可生成包含可打印字符的随机密码。用户可通过命令行参数指定密码长度(默认为 9 个字符)和生成的密码数量(默认为 1 个)。脚本通过从 /dev/urandom 读取随机数据,并进行一系列处理来生成密码。
📄作者提供了脚本的下载链接,方便用户获取和使用。同时,还提到了通过特定命令行参数的示例来生成指定长度和数量的密码,如 #randompass.sh 7 7 。
🌐作者在文中提及了自己的社交媒体信息,如 LinkedIn 账号,以便读者关注其在 LinkedIn、Github、博客等平台上发布的更多内容。
Here I stumbled on an intro into Bash scripting for NetOps by John Kristoff " Introduction to Shell and Perl scripting for Network Operators" https://www.cymru.com/jtk/talks/nanog54-intro-scripting.pdf and could't help but do it my way. Here it is, bash script that generates random password of printable characters, up to 15 at least.
1 2 3 4 5 6 7 8 91011121314 | #!/bin/bash# usage: randompass.sh [n] [count] - n is number of characters in password# to generate 9 by default, and count - number of passwords to generate, 1 by defaultn=${1:-9}counter=${2:-1}for ii in `seq 1 $counter` ;dodd count=1 bs=15 if=/dev/urandom 2>/dev/null | od -a | sed '2d' | sed 's/0000000 \(.*\)/\1/' | tr -d ' ' | cut -c 1-$n | sed 's/\([a-z]\)/\U&/3' | sed 's/\([A-Z]\)/\l&/4'done
|
Download the script Example.
#randompass.sh 7 7
o&sOh;~KdeL(HMddc23DBgHK?S@iE_$SL*Adsi|}Del%I-ba<B
Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.