/etc/login.defs 文件
/etc/login.defs 文件提供默认用户帐户设置。
默认值包括:
- 用户邮箱的位置
- 密码时效控制
- 自动 UID 选择的值
- 自动 GID 选择的值
- 用户主目录创建选项
- 掩码值
- 用于加密密码的加密方法
示例 /etc/login.defs 文件:
# cat /etc/login.defs ..... PASS_MAX_DAYS 99999 PASS_MIN_DAYS 0 PASS_MIN_LEN 5 PASS_WARN_AGE 7 ...... GID_MIN 1000 GID_MAX 60000 ..... UID_MIN 1000 UID_MAX 60000
欢迎来到之路教程(on itroad-com)
验证配置
Linux 用户密码散列算法也是可配置的。
使用 authconfig 命令确定当前使用的算法,或者将其设置为不同的算法。
要确定当前算法:
# authconfig --test | grep hashing password hashing algorithm is sha512
要更改算法,请使用 -passalgo 选项和以下选项之一作为参数:descrypt、bigcrypt、md5. sha256 或者 sha512,后跟 -update 选项。
# authconfig --passalgo=md5 --update
更改选项
chage 命令中可用的选项数量。
列出老化信息:
# chage -l geek Last password change : Sep 18, 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
要强制用户立即设置新密码(强制立即过期),请将最后一次密码更改值设置为 0 :
# chage -d 0 geek
密码配置
密码老化要求用户定期更改密码。
使用 chage 配置密码过期。
语法是:
# chage [options] user_name
当我们触发命令 chage 时,也会显示当前设置的选项。
# chage oracle Changing the aging information for oracle Enter the new value, or press ENTER for the default Minimum Password Age [14]: Maximum Password Age [30]: Last Password Change (YYYY-MM-DD) [2016-08-23]: Password Expiration Warning [7]: Password Inactive [-1]: Account Expiration Date (YYYY-MM-DD) [1969-12-31]:
密码过期信息存储在 /etc/shadow 文件中。
# grep oracle /etc/shadow oracle:$H28sLVDL$iNvp/AvbMeqqrslH2bfmTxJpE6.mO8UNzlIXGB3sp87jZP9dW1DxeoLf2QXR7hkLkomuXbtgO1zPKUEYRY8YI1:15284:14:30:7:::
如上图所示,oracle 用户的密码最小年龄为 14 岁,密码最大年龄为 30 岁,这意味着在 14 天内用户将有 30 天的时间更改密码。
此外,用户会被警告在密码到期日期前 7 天更改密码。
日期:2020-09-17 00:14:09 来源:oir作者:oir