linux密码过期 程序会关闭吗

博客访问: 251063
博文数量: 251
博客积分: 52
博客等级: 民兵
技术积分: 1056
注册时间:
感谢互联网让我每天学这么多东西,希望五年以后能成为架构师足以
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: LINUX
原文地址: 作者:
&&& 对于新添加的用户,用户密码过期时间是从/etc/login.defs中PASS_MAX_DAYS提取的,普通系统默认就是99999,而有些安全操作系统是90。更改此处,只是让新建的用户默认密码过期时间变化,已有用户密码过期时间仍然不变。
[sysman@SHWeb3 ~] sudo chage --help
chage: invalid option -- -
Usage: chage [-l] [-m min_days] [-M max_days] [-W warn]
[-I inactive] [-E expire] [-d last_day] user
[sysman@SHWeb3 ~] sudo man chage
CHAGE(1)&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
chage - change user password expiry information
chage [-m mindays] [-M maxdays] [-d lastday] [-I inactive]
&&&&&&&&&&&&
[-E expiredate] [-W warndays] user
chage:密码失效是通过此命令来管理的。
  参数意思:
  -m 密码可更改的最小天数。为零时代表任何时候都可以更改密码。
  -M 密码保持有效的最大天数。
  -W 用户密码到期前,提前收到警告信息的天数。
  -E 帐号到期的日期。过了这天,此帐号将不可用。
  -d 上一次更改的日期
  -i 停滞时期。如果一个密码已过期这些天,那么此帐号将不可用。
  -l 例出当前的设置。由非特权用户来确定他们的密码或帐号何时过期。
[sysman@SHWeb3 ~]$ sudo chage -l root
Minimum:&&&&&&&
Maximum:&&&&&&&
Warning:&&&&&&&
Inactive:&&&&&&
Last Change:&&&&&&&&&&&
Mar 15, 2010
Password Expires:&&&&&&
Password Inactive:&&&&&
Account Expires:&&&&&&&
&&& 更改用: sudo chage -M 90 root
[sysman@SHWeb3 ~]$ sudo chage -M 90 root
[sysman@SHWeb3 ~]$ sudo chage -l root
Minimum:&&&&&&&
Maximum:&&&&&&&
Warning:&&&&&&&
Inactive:&&&&&&
Last Change:&&&&&&&&&&&
Jun 08, 2010
Password Expires:&&&&&&
Sep 06, 2010
Password Inactive:&&&&&
Account Expires:&&&&&&&
&&& 如果以后添加一个用户,那么默认的时间还是没改的,还必须得去/etc/login.defs修改PASS_MAX_DAYS
的默认值.那么如果我直接修改全局/etc/login.defs所在的用户会跟着改变吗?
据我的测试是不会改变的,除非重启后,但我们的服务器不是你想重启的就可以重启的!如果管理严格的地方,重启还得经过很多程序步骤.改完全局时,没有更改
的用户,想要让他也同样具备此功能.就得一个个的执行!
&&& 你也可以直接用vim 编辑器去编辑PASS_MAX_DAYS 99999
&&& 也可以用其它的工具
sudo sed -i.bak -e 's/^\(PASS_MAX_DAYS\).*/\1&&
90/' /etc/login.defs
&&& 查看一下是否
sudo cat /etc/login.defs |grep "PASS_M";
&&& 强制用户登陆时修改口令
chage -d 0 username(linux)
passwd -f username(solaris)
&&& 强制用户下次登陆时修改密码,并且设置密码最低有效期0和最高有限期90,提前15天发警报提示
chage -d 0 -m 0 -M 90 -W 15 root(linux)
passwd -f -n 0 -x 90 -w 15 root(solaris)
&&& 查看某个用户的密码设置情况
chage -l username
&&& 修改密码配置文件
/etc/login.defs
阅读(146) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。linux(72)
法一:添加用户时
useradd yongge-e 01/28/12
或修改下面文件的参数:
[root@yonggeskel]
实例7:指定参数执行useradd -D -e
[root@yongge~]
2012-01-25
[root@yongge~]
[root@yongge~]
EXPIRE=01/19/12
[root@yongge~]
[root@yongge~]
最近一次密码修改时间
: 1月 24, 2012
密码过期时间
密码失效时间
帐户过期时间
: 1月 19, 2012
#→就是修改的默认的过期时间。
两次改变密码之间相距的最小天数
两次改变密码之间相距的最大天数
在密码过期之前警告的天数
[root@yongge~]
[root@yongge~]
HOME=/home
INACTIVE=-1
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
特别提示:这里仅是更改了配置文件的默认值,仅对之后建立的新用户生效,和老用户无关。
更改用户时:
法二:修改账户属性
usermod -e 01/28/12 oldboy
法三:调整账户过期
chage -E 01/28/12 oldboy
查看帐户过期:
chage -l oldboy
配置可以脚本化,在每个阶段传个时间参数即可。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:109622次
积分:2458
积分:2458
排名:第15990名
原创:130篇
转载:28篇
(8)(11)(8)(43)(62)(31)
(window.slotbydup = window.slotbydup || []).push({
id: '4740887',
container: s,
size: '250,250',
display: 'inlay-fix'linux(44)
解决思路是:linux系统用户密码是有使用期限的,密码过期就需要用户修改密码,只要让用户密码立即过期,就可以实现让客户登录系统就更改密码。
可以使用chage命令来实现:
chage -d 0 username & & &#意思是密码最近一次修改时间为 ,会强制用户下次登陆时修改密码
用法:chage [选项] 用户名
-d, --lastday 最近日期 将最近一次密码设置时间设为&最近日期&
-E, --expiredate 过期日期 将帐户过期时间设为&过期日期&
-h, --help 显示此帮助信息并退出
-I, --inactive 失效密码 将因过期而失效的密码设为&失效密码&
-l, --list 显示帐户年龄信息
-m, --mindays 最小天数 将两次改变密码之间相距的最小天数设为&最小天数&
-M, --maxdays 最大天数 将两次改变密码之间相距的最大天数设为&最大天数&
-W, --warndays 警告天数 将过期警告天数设为&警告天数&
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:90376次
积分:1735
积分:1735
排名:千里之外
原创:83篇
转载:19篇
(9)(9)(1)(1)(1)(4)(1)(7)(1)(2)(5)(4)(2)(7)(6)(4)(5)(6)(27)
(window.slotbydup = window.slotbydup || []).push({
id: '4740881',
container: s,
size: '200,200',
display: 'inlay-fix'修改了 /etc/login.defs下参数时,会立即生效,但是它只对修改后创建的用户生效。例如修改了PASS_MAX_DAYS参数等后,我们新建一个用户test。
[root@DB-Server home]# useradd test
[root@DB-Server home]# cat /etc/shadow | grep test
test:!!::7:::
[root@DB-Server home]# cat /etc/passwd | grep test
test:x:501:501::/home/test:/bin/bash
[root@DB-Server home]# chage -l test
Last password change&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : Jun 19, 2016
Password expires&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : Aug 18, 2016
Password inactive&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : never
Account expires&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : never
Minimum number of days between password change&&&&&&&&& : 0
Maximum number of days between password change&&&&&&&&& : 60
Number of days of warning before password expires&&&&&& : 7
[root@DB-Server home]#
因为CREATE_HOME为yes,所以创建用户test后,就会默认在/home目录下创建test目录,这个可以在添加用户的规则文件/etc/default/useradd里面查看或修改
[root@DB-Server ~]# cat /etc/default/useradd
# useradd defaults file
HOME=/home&&&&&&& #把用户的主目录建在/home中
INACTIVE=-1&&&&&& #是否启用帐号过期停权,-1表示不启用
EXPIRE=&&&&&&&&&& #帐号终止日期,不设置表示不启用;
SHELL=/bin/bash&& #所用SHELL的类型;
SKEL=/etc/skel&&& #默认添加用户的目录默认文件存放位置;也就是说,当我们用adduser添加用户时,用户家目录下的文件,都是从这个目录中复制过去的
CREATE_MAIL_SPOOL=yes
如果此时,假如用户test有特殊需求,要求这个账号的密码永不过期,此时就可以使用chage命令来处理(关于chage命令,此处不做展开)
[root@DB-Server ~]# chage -l test
Last password change&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : Jun 19, 2016
Password expires&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : Aug 18, 2016
Password inactive&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : never
Account expires&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : never
Minimum number of days between password change&&&&&&&&& : 0
Maximum number of days between password change&&&&&&&&& : 60
Number of days of warning before password expires&&&&&& : 7
You have new mail in /var/spool/mail/root
[root@DB-Server ~]# chage -M 99999 test
[root@DB-Server ~]# chage -l test
Last password change&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : Jun 19, 2016
Password expires&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : never
Password inactive&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : never
Account expires&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& : never
Minimum number of days between password change&&&&&&&&& : 0
Maximum number of days between password change&&&&&&&&& : 99999
Number of days of warning before password expires&&&&&& : 7
[root@DB-Server ~]#
如上所示/etc/login.defs只是控制了账号的最小长度以及控制密码的有效期等,那么Linux是如何实现对用户的密码的复杂度的检查的呢?其实系统对密码的控制是有两部分组成:
<span style="font-family:宋体; color:# cracklib
<span style="font-family:宋体; color:# /etc/login.defs
pam_cracklib.so 才是控制密码复杂度的关键文件/lib/security/pam_cracklib.so, Redhat公司专门开发了cracklib这个安装包来判断密码的复杂度。如果你想查看pam_cracklib的一些参数,那么就使用下面命令
[root@DB-Server security]# man pam_cracklib
其中一些常见的参数为
改变输入密码的次数,默认&#20540;是1。就是说,如果用户输入的密码强度不够就退出。可以使用这个选项设置输入的次数,以免一切都从头再来
&&&&&&&&&&&&& Prompt user at most N times before returning with error. The
&&&&&&&&&&&&& default is 1
新密码最低可接受的长度
&&&&&&&&&&&&& The minimum acceptable size for the new password (plus one if
&&&&&&&&&&&&& credits are not disabled which is the default). In addition to the
&&&&&&&&&&&&& number of characters in the new password, credit (of &#43;1 in length)
&&&&&&&&&&&&& is given for each different kind of character (other, upper, lower
&&&&&&&&&&&&& and digit). The default&for this parameter is 9 which is good for a
&&&&&&&&&&&&& old style UNIX password all of the same type of character but may
&&&&&&&&&&&&& be too low to exploit the added security of a md5 system. Note that
&&&&&&&&&&&&& there is a pair of length limits in Cracklib itself, a &way too
&&&&&&&&&&&&& short& limit of 4 which is hard coded in and a defined limit (6)
&&&&&&&&&&&&& that will be checked without reference to minlen. If you want to
&&&&&&&&&&&&& allow passwords as short as 5 characters you should not use this
&&&&&&&&&&&&& module.
默认&#20540;为10。这个参数设置允许的新、旧密码相同字符的个数。不过,如果新密码中1/2的字符和旧密码不同,则新密码被接受
&&&&&&&&&&&&& This argument will change the default of 5 for the number of
&&&&&&&&&&&&& characters in the new password that must not be present in the old
&&&&&&&&&&&&& password. In addition, if 1/2 of the characters in the new password
&&&&&&&&&&&&& are different then the new password will be accepted anyway.
限制新密码中至少有多少个数字
&&&&&&&&&&&&& (N &= 0) This is the maximum credit for having digits in the new
&&&&&&&&&&&&& password. If you have less than or N digits, each digit will count
&&&&&&&&&&&&& &#43;1 towards meeting the current minlen value. The default&for
&&&&&&&&&&&&& dcredit is 1 which is the recommended value for minlen less than
&&&&&&&&&&&&& 10.
&&&&&&&&&&&&& (N & 0) This is the minimum number of digits that must be met for a
&&&&&&&&&&&&& new password.
限制新密码中至少有多少个大写字符。
限制新密码中至少有多少个小写字符。
例如在/etc/pam.d/system-auth 在password使用pam_cracklib.so设置的最后附加dcredit=3 ucredit=2
password&&& requisite&&&& pam_cracklib.so try_first_pass retry=3 dcredit=3 ucredit=2
password&&& sufficient&&& pam_unix.so md5 shadow nullok try_first_pass use_authtok
password&&& required&&&&& pam_deny.so
此时如果你新建用户的密码不符合密码复杂度,就会出现BAD PASSWORD: it is based on a dictionary word提示。
[root@DB-Server ~]# passwd ttt
Changing password for user ttt.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
参考资料:
如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨小小打赏一下吧,如果囊中羞涩,不妨帮忙“推荐&一下,您的“推荐”和”打赏“将是我最大的写作动力!
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.
本文已收录于以下专栏:
相关文章推荐
Authentication toke new one required
You (mysql) are not allowed to access ...
AppArmor&#160;是一个类似于selinux 的东东,主要的作用是设置某个可执行程序的访问控制权限,可以限制程序
读/写某个目录/文件,打开/读/写网络端口等等。
&#160; &#160; Novell给出的...
=====================
1、每个人用自己名字的账户和密码登陆服务器(便于追踪用户操作,记录用户行为)
2、只允许指定组(或用户)使用sudo命令(最好还要禁止roo...
六招轻松搞定你的CentOS系统安全加固
Redhat是目前企业中用的最多的一类Linux,而目前针对Redhat攻击的黑客也越来越多了。我们要如何为这类服务器做好安全加固工作呢...
1.linux 账号周期策略 出于安全性的考虑,linux系统中需要对密码周期进行限制,其中/etc/login.defs就是对用户周期进行设置,在/etc/login.defs中我们可配置密码的最大...
indows Logon Process,Windows NT 用户登陆程序,管理用户登录和退出。
因为登陆的域名和用户名是明文存储在winlogon进程里的,而Password是限定了查找本进...
在嵌入式平台下当wifi驱动移植好之后,我们可以用Wireless和wpa_spplicant工具进行网络的配置,这两个工具的具体移植方法这里不再讲述!但是此时我们会发现我们上网都是通过wpa_spp...
mysql& SHOW VARIABLES LIKE &#39;validate_password%&#39;;
+--------------------------------------+--------+
我们现在处于网络时代,时常要登录各种网站、论坛、邮箱、网上银行等等,这些访问常需要帐户+密码的身份认证,因此我们不断地注册用户,就有了数不清的网络帐户和密码。大多数人为了便于记忆,习惯只用一个常用的网...
他的最新文章
讲师:汪剑
讲师:刘道宽
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)

我要回帖

 

随机推荐