本文译自 7 Examples to Manage Linux Password Expiration and Aging Using chage

  本文主要介绍命令chage的使用,译文会对原文内容会有一定的简化。

  debian系统可以通过如下命令安装chage: (chage is for change age)

apt-get install chage

  CentOS7 应该是自带这个命令了。

列出用户密码相关信息

Syntax: chage –-list username (or) chage -l username

$ chage --list dhinesh
Last password change : Apr ,
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :

  注:普通用户对其它用户执行这条命令,但root用户可以

修改下密码

$ date
Thu Apr :: PDT $ passwd dhinesh
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully $ chage --list dhinesh
Last password change : Apr ,
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :

  可以看出上次密码修改的时间已经发生了变化。

通过选项-M 设置账户密码的到期时间

Syntax: # chage -M number-of-days username

# chage -M  dhinesh

# chage --list dhinesh
Last password change : Apr ,
Password expires : May ,
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :

  密码到期时间变成了十天后。

密码过期消息提醒

  如上,密码过期之前7天会提示密码过期,假如dhinesh 试图在Apr 30, 2009登录,那么将会出现如下提醒消息:

$ ssh dhinesh@testingserver
dhinesh@testingserver's password:
Warning: your password will expire in days

密码过期时,强制用户修改密码

$ ssh dhinesh@testingserver
dhinesh@testingserver's password:

You are required to change your password immediately (password aged)

WARNING: Your password has expired.
You must change your password now and login again!
Changing password for dhinesh
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:

设置账户过期时间

  可以使用-E选项设置账户的过期时间,时间格式为“YYYY-MM-DD”。

# chage -E "2009-05-31" dhinesh

# chage -l dhinesh
Last password change : Apr ,
Password expires : May ,
Password inactive : never
Account expires : May ,
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :

设置用户不活跃锁定

  当用户密码过期后,可以设置用户多少天不活跃即锁定账户,如10天。

# chage -I  dhinesh

# chage -l dhinesh
Last password change : Apr ,
Password expires : May ,
Password inactive : May ,

Account expires : May ,
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :

设置用户账户不过期

  取消用户账户过期设置。

-m  will set the minimum number of days between password change to
-M will set the maximum number of days between password change to
-I - (number minus one) will set the “Password inactive” to never
-E - (number minus one) will set “Account expires” to never.
# chage -m  -M  -I - -E - dhinesh

# chage --list dhinesh
Last password change : Apr ,
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :

以上!

[译]使用chage来管理Linux密码过期时间的七个例子的更多相关文章

  1. linux 用户密码过期时间

    /etc/login.defs    全局配置文件,即当新建用户时的默认设置 PASS_MIN_DAYS  5    #最近一次密码更新的日期+0 ,即允许用户更改自己的密码的日期 PASS_MAX_ ...

  2. Linux 密码过期(WARNING:Your password has expired )

    最近遇到两次这个问题,我们公司用的是开源的堡垒机Jumpserver但是最近有两个同学遇到了 WARNING:Your password has expired 第一次遇到这个问题也没有往深了去查,当 ...

  3. oracle修改用户密码过期时间

    Oracle默认在default概要文件中设置了“PASSWORD_LIFE_TIME=180天”,导致密码过期,程序无法使用,业务进程会提示无法连接数据库等字样. --查询默认密码过期时间 SELE ...

  4. (Oracle)数据库用户的密码过期时间如何修改为永不过期

    Oracle的密码过期规则是用Profile来管理的,系统默认只有一个Profile(DEFAULT),该profile的密码过期规则为180天.那么如何修改Oracle数据库用户的密码过期时间为永不 ...

  5. Oracle密码概要文件,密码过期时间180天修改为3天,相关用户密码是否过期

    #Oracle用户密码,概要文件修改测试 #默认的用户使用概要文件,默认概要文件密码过期时间参数180天,修改为3天,对于老的用户来说,是密码过期,还是未发生改变, 对于新用户来说,新设置的密码过期时 ...

  6. Sqlserver 密码过期时间查询

    DECLARE @login nvarchar(30) -- 查询设定密码过期的登陆账号SELECT @login = nameFROM sys.sql_loginsWHERE is_expirati ...

  7. 解除 linux 账户过期时间

    riyimei:~ # chage -E 2019/01/01 li Aging information changed. riyimei:~ # cat /etc/shadow |grep li l ...

  8. linux初级学习笔记七:linux用户管理,密码和组命令详解!(视频序号:04_1)

    本节学习的命令: 用户管理命令:useradd,userdel,id,finger,usermod,chsh,chfn,passwd,pwck, 组管理命令:groupadd,groupmod,gro ...

  9. 用户管理-linux基础

    用户管理 useradd -u -g -G(附加组) ,-c -d -s -r(创建系统用户)   -M (不创建家目录)    思考:删除user1用户家目录,如何还原.        可以#cp ...

随机推荐

  1. 强化学习算法DQN

    1 DQN的引入 由于q_learning算法是一直更新一张q_table,在场景复杂的情况下,q_table就会大到内存处理的极限,而且在当时深度学习的火热,有人就会想到能不能将从深度学习中借鉴方法 ...

  2. 微软职位内部推荐-Software Development Engineer II_Commerce

    微软近期Open的职位: Are you looking for a high impact project that involves processing of billions of dolla ...

  3. SCRUM 12.03

    第二轮迭代从今天起正式开始了.12月3日,我们举行了一次组会. 第一轮迭代结束时,我们意识到第二轮迭代需要实现的功能主要如下: 在下次迭代的时候实现对多个网站的信息进行比较取最优惠的选择,目前我们劲针 ...

  4. "软件"和"软件工程"一词最早被谁提出?

    1."softwar”:1953年Richard R.Carhart在备忘录中使用software一词2.软件工程 1968 年北大西洋公约组织在前联邦德国开会提出的 1968年秋季,NAT ...

  5. Win 2008 r2 远程桌面多用户登陆,一用户多登陆配置

    Windows 2008 R2远程桌面,设置最大连接数,一个登录后另一个就被踢掉等问题 Windows 2008 R2配置如图: 1.打开远程桌面回话主机配置 2.右键RDP-Tcp,属性,可设置最大 ...

  6. Razor - 标记简述

    详情请参考:http://www.runoob.com/aspnet/razor-intro.html 1.Razor 不是一种编程语言.它是服务器端的标记语言.基于服务器的代码(Visual Bas ...

  7. Beta冲刺——day3

    Beta冲刺--day3 作业链接 Beta冲刺随笔集 github地址 团队成员 031602636 许舒玲(队长) 031602237 吴杰婷 031602220 雷博浩 031602134 王龙 ...

  8. 初征——NOIP2018游记

    前言 从最初接触oi到今年noip到来,也已经将近有一年了.从对于程序一窍不懂到现在开始学习算法,只是短短的不到一年的时间罢了.这次noip,不仅仅是我oi生涯的第一次noip,更是相当于是对我这一年 ...

  9. 【BZOJ1037】[ZJOI2008]生日聚会(动态规划)

    [BZOJ1037][ZJOI2008]生日聚会(动态规划) 题面 BZOJ 洛谷 题解 假设前面的都合法,但是在加完当前的最后一个人之后变得不合法了,那么意味着一定有着一个后缀不合法.把男生看成\( ...

  10. emWin 界面切换注意事项

    @2018-07-10  emWin 在做界面切换时,须将切换前的界面所有信息 “删除”,否则将造成切换后的界面死机 此 “删除” 对象包括: > 界面上绘制的曲线(随时间一直变化).绘制的2D ...