cev*_*ing 6 password centos shadow passwd
CentOS 6 Linux 有两种锁定密码的方法:
passwd -l
usermod -L
今天我发现,他们做了一些不同的事情。
passwd
将两个感叹号写入影子文件。
# passwd -d test1 删除用户 test1 的密码。 密码:成功 # passwd -l test1 锁定用户 test1 的密码。 密码:成功 # passwd -S test1 test1 LK 2014-01-14 0 99999 7 -1(密码锁定。) # grep test1 /etc/shadow test1::!!:16084:0:99999:7:::
但是usermod
只写一个。
# passwd -d test1 删除用户 test1 的密码。 密码:成功 # usermod -L test1 # passwd -S test1 test1 LK 2014-01-14 0 99999 7 -1(密码锁定。) # grep test1 /etc/shadow test1::!:16084:0:99999:7:::
这只是外观上的不一致还是不同的锁定指示器有含义?
如果混合使用这两个命令,就会发生有趣的事情:
锁定帐户passwd
:
# passwd -l test1
Locking password for user test1.
passwd: Success
Run Code Online (Sandbox Code Playgroud)
解锁usermod
:
# usermod -U test1
Run Code Online (Sandbox Code Playgroud)
令人惊讶的是它仍然被锁定:
# passwd -S test1
test1 LK 2014-01-14 0 99999 7 -1 (Password locked.)
Run Code Online (Sandbox Code Playgroud)
错误或功能?
bah*_*mat 10
没关系。您看到的行为是特定于实现的。这就是为什么usermod
做一件事并passwd
做另一件事。它们是不同的实现。看看在 Solaris、AIX、HP-UX、True64、Xenix 上发生了什么……
密码字段是加密或散列的字符串。当用户提供密码时,它会根据密码字段中指定的算法进行加密或散列。仅当提供的和存储的加密/散列形式匹配时,身份验证才会成功。
单个!
或两个!!
永远无法匹配任何加密密码。换句话说,没有任何输入会加密到结果值!
或!!
. 任何永远不会成为哈希结果的字符串都将“锁定”帐户。它也可能是foo
或Mr. Spock
。
另请注意Linux 上--lock
标记下的此评论passwd(1)
:
请注意,这不会禁用该帐户。用户可能仍然能够使用另一个身份验证令牌(例如 SSH 密钥)登录。要禁用该帐户,管理员应使用
usermod --expiredate 1
(这将帐户的到期日期设置为 1970 年 1 月 2 日)。
这听起来像是一个错误,但很可能完全是装饰性的,只要您使用一种工具或另一种工具,而不是同时使用!如果您查看 shadow 手册页 ( man 5 shadow
),它会说明密码字段(在 CentOS 上)。
encrypted password
Refer to crypt(3) for details on how this string is interpreted.
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.
Run Code Online (Sandbox Code Playgroud)
最后一段会使问题听起来像是passwd
命令中的一个实现错误,因为!
锁定密码只需要一个 ( ) 即可。
令我感到困扰的一件事是,这是一个错误的上述潜力,我无法想象它会持续这么长时间。另一件困扰我的事情是,在我的/etc/shadow
文件中,我有如下几行:
abrt:!!:16047::::::
openvpn:!!:16047::::::
unbound:!!:16047::::::
Run Code Online (Sandbox Code Playgroud)
因此,我进行了更多搜索,发现了这篇题为:Understanding /etc/shadow file 的文章。在这篇文章的评论部分是以下几点:
lesca September 23, 2010 at 4:29 am
!! means user account has not been initialed or has not been locked.
! means group password is not available.
* means login disabled.
Run Code Online (Sandbox Code Playgroud)
最后一点让我想起了在不太遥远的过去曾经有组密码和用户密码。您可以在这篇题为:Linux 设置或更改用户密码的博文中阅读更多关于它们的信息,以及gpasswd
在这篇题为:Linux 中的组密码 的博文中替换的功能。
无论如何,我相信您已经发现了一个错误!错误在passwd
命令中。
归档时间: |
|
查看次数: |
34274 次 |
最近记录: |