关闭。这个问题需要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/