Centos7 安全加固密碼規則
vi /etc/login.defs
PASS_MAX_DAYS 60 # 密碼到期時間
#設置密碼過期的天數。 用戶必須在幾天內更改密碼。 此設置僅在創建用戶時才會產生影響,而不會影響到現有用戶。 如果設置為現有用戶,請運行命令“chage -M(days)(user)”
PASS_MIN_DAYS 3 # 初始密碼更改時間
#設置可用密碼的最短天數。 至少在改變它之后,用戶必須至少使用他們的密碼。 此設置僅在創建用戶時才會產生影響,而不會影響到現有用戶。 如果設置為現有用戶,請運行命令“chage -m(days)(user)”
PASS_MIN_LEN 8 # 密碼最小長度
#用戶不能將密碼長度設置為小於此參數。
PASS_WARN_AGE 7 # 密碼過期提示時間
#在到期前設置警告的天數。 此設置僅在創建用戶時才會產生影響,而不會影響到現有用戶。 如果設置為存在用戶,請運行命令“chage -W(days)(user)”
賬號鎖定規則
vi /etc/pam.d/login
#%PAM-1.0
auth required pam_tally2.so deny=3 lock_time=300 even_deny_root root_unlock_time=10
deny 設置普通用戶和root用戶連續錯誤登陸的最大次數,超過最大次數,則鎖定該用戶
unlock_time 設定普通用戶鎖定后,多少時間后解鎖,單位是秒;
even_deny_root 也限制root用戶;
root_unlock_time 設定root用戶鎖定后,多少時間后解鎖,單位是秒;
Centos7 ssh和vsftp限制IP登錄白名單和黑名單(白名單優先級大於黑名單)
vi /etc/hosts.deny (黑名單)
最后面加上兩行代碼的意思是,限制sshd和vsftpd服務所有IP登陸
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd:ALL
vsftpd:ALL
vi /etc/hosts.allow (白名單)
最后面加上的代碼意思是,該IP可以訪問sshd和vsftpd服務
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
#sshd
sshd:192.168.199.171:allow
#vsfptd
vsftpd:192.168.199.171:allow