Linux强制用户首次登陆修改密码

@lianst  November 3, 2017

Linux强制用户首次登陆修改密码这个应该是RHCE认证中用户管理部分,属于基础中的基础。可是我忘记了,所以就有了下面的记录。

[root@jd /]# useradd testuser1
[root@jd /]# echo "123456" | passwd testuser1 --stdin
Changing password for user testuser1.
passwd: all authentication tokens updated successfully.
[root@jd /]# chage -d0 testuser1

使用testuser1用户登陆到服务器

[root@qcloud conf]# ssh testuser1@116.196.107.126 -p 22860
The authenticity of host '[116.196.000.000]:22 ([116.196.000.000]:22)' can't be established.
ECDSA key fingerprint is 6f:8c:31:66:d8:e5:11:18:e8:3a:4a:39:56:6f:1f:ec.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[116.196.000.000]:22860' (ECDSA) to the list of known hosts.
testuser1@116.196.000.000's password: 
You are required to change your password immediately (root enforced)

WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user testuser1.
Changing password for testuser1.
(current) UNIX password:    //输入当前密码
New password:     //新密码
Retype new password:   //再次输入
passwd: all authentication tokens updated successfully.

chage命令说明

chage –help:
-m 密码可更改的最小天数。为零时代表任何时候都可以更改密码。
-M 密码保持有效的最大天数。
-W 用户密码到期前,提前收到警告信息的天数。
-E 帐号到期的日期。过了这天,此帐号将不可用。
-d 上一次更改的日期
-i 停滞时期。如果一个密码已过期这些天,那么此帐号将不可用。
-l 例出当前的设置。由非特权用户来确定他们的密码或帐号何时过期。

添加新评论