在 /etc/shadow 的密码部分中,"!" 和 "*" 代表什么意思?

9
在/etc/shadow文件中,它看起来像以下内容。
root:!:15764:0:99999:7:::
daemon:*:15749:0:99999:7:::

密码区域中的这些字符(“!”和“*”)代表什么意思?
3个回答

14

man shadow

   If the password field contains some string that is not a valid
   result of crypt(3), for instance ! or *, the user will not be able
   to use a unix password to log in (but the user may log in the
   system by other means).

   This field may be empty, in which case no passwords are required to
   authenticate as the specified login name. However, some
   applications which read the /etc/shadow file may decide not to
   permit any access at all if the password field is empty.

   A password field which starts with a exclamation mark means that
   the password is locked. The remaining characters on the line
   represent the password field before the password was locked.

因此,*表示不能使用密码访问帐户,而表示它被锁定。


2
注意:两者是相同的。 - Константин Ван

4

来自手册页shadow(5)

加密密码
有关如何解释此字符串的详细信息,请参阅crypt(3)。

如果密码字段包含一些不是crypt(3)的有效结果的字符串,例如*,则用户将无法使用unix密码登录(但用户可以通过其他方式登录系统)。

此字段可能为空,在这种情况下,不需要密码即可验证指定的登录名。但是,读取/etc/shadow文件的某些应用程序可能会决定如果密码字段为空,则不允许任何访问。

此外,程序passwd(请参见passwd(1))可以通过在密码前加上来锁定以创建这些锁定帐户:

-l,--lock
锁定命名帐户的密码。此选项通过将密码更改为与没有可能的加密值匹配的值来禁用密码(在密码开头添加“!”)。


-4

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接