cut
: 取出user.txt的第二个字段(密码明文),将结果输出到stdout;openssl
: 将stdin中输入的数据(3条密码明文)使用SHA512形式进行hash,输出到stdout;paste
: 将user.txt中的原始内容与hash过的密码组合起来,输出到stdout;tr
: 去除可能出现的\r符号;awk
: 从stdin中提取出用户名、hash过的密码、注释字段,将结果输出到passwd.txt。
OpenSSL 的帮助命令可以看出当前的 openssl
命令支持哪些加密方式。
openssl help passwd
$ openssl help passwd
Usage: passwd [options]
Valid options are:
-help Display this summary
-in infile Read passwords from file
-noverify Never verify when reading password from terminal
-quiet No warnings
-table Format output as table
-reverse Switch table columns
-salt val Use provided salt
-stdin Read passwords from stdin
-6 SHA512-based password algorithm
-5 SHA256-based password algorithm
-apr1 MD5-based password algorithm, Apache variant
-1 MD5-based password algorithm
-aixmd5 AIX MD5-based password algorithm
-crypt Standard Unix password algorithm (default)
-rand val Load the file(s) into the random number generator
-writerand outfile Write random data to the specified file
可以根据参数自行修改加密参数。