centos – useradd不加密/ etc / shadow中的密码

在尝试为vsftpd创建新的FTP用户时,我偶然发现了这个问题.
在使用以下命令创建新用户并尝试使用FileZilla登录时,我会收到“密码错误错误.
useradd f -p pass -d /home/f -s /bin/false

执行此操作后,/ etc / shadow包含

f:pass:1111:0:99:2:::

一旦我运行以下命令并提供相同的pass pass

passwd f

/ etc / shadow包含

f:$1$U1c5vVwg$x5TVDDDmhi0a7RWFer6Jn1:1111:0:99:2:::

似乎加密发生在我运行passwd时,但不是在useradd上

重要的是,在执行此操作后,我可以使用完全相同的凭据登录FTP.

我使用的是CentOS 5.11,vsftpd用于FTP,FileZilla用于FTP访问

/ var / log / secure包含:

Dec 17 useradd[644]: new group: name=f,GID=511
Dec 17 useradd[644]: new user: name=f,UID=511,GID=511,home=/home/f,shell=/bin/false

当我将-p传递给useradd时,为什么它不起作用?我需要做些什么来使它工作?

这是按预期工作的.如果要使用useradd命令设置密码,则应该为useradd提供密码的哈希版本.

字符串传递确实满足/ etc / shadow中哈希密码字段的格式标准,但没有实际密码哈希到该字符串.结果是,对于所有意图和目的,该帐户将表现为具有密码,但是您尝试用来访问它的任何密码都将被拒绝,因为它们不是正确的密码.

请参阅man useradd或useradd documentation

-p,--password PASSWORD

The encrypted password,as returned by 07001. The default is
to disable the password.

Note: This option is not recommended because the password (or
encrypted password) will be visible by users listing the processes.

You should make sure the password respects the system’s password policy.

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native