linux - 如何使用 perl 正确散列我的密码?

标签 linux shell perl ubuntu crypt

关闭。这个问题需要debugging details .它目前不接受答案。












编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将帮助其他人回答问题。


1年前关闭。







Improve this question




在使用脚本添加用户时,我尝试使用 perl 对我的密码进行哈希处理,但是当我尝试切换到该用户时,它说密码不正确。这是我写的:

hidden=$(perl -e 'print crypt($pass, "salt"),"\n")
useradd -m -p $hidden -d /home/$user -s /bin/bash $user 
在此之上,我归因于“通过”我的新密码和“用户”我的新用户名。

最佳答案

您似乎想使用 $pass来自 shell 环境,但在 Perl 解释器中,它看起来像 Perl 变量 $perl .
尝试

hidden=$(perl -e 'print crypt($ENV{pass}, "salt")')
引用pass环境变量。

关于linux - 如何使用 perl 正确散列我的密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64940678/

相关文章:

linux - Gunicorn 调试 sock 文件的权限被拒绝

multithreading - Perl:使用多线程构建复杂对象树

bash - ssh,nohup,然后将结果复制回去

linux - "visudo: Warning: Cmnd_Alias ` NOPASSWD'引用但未定义,“是什么意思?

perl - 如何在 Perl 中输入多行注释?

Perl 脚本在信号处理程序中重新打开文件

linux - Linux 串行默认 shell 上的 IP 隧道

linux - tar 排除特定路径上的错误输出

linux - 批量重命名文件以包含Linux中的文件夹/目录名称

linux - 用于从 shell 启动的命令的标准输入/标准输出