赞
踩
编辑/etc/pam.d/password-auth 和/etc/pam.d/system-auth 文件,以符合本地站点策略:建议严格按照顺序插入,修改之前记得备份。
auth required pam_faillock.so preauth audit silent deny=5 unlock_time=900
auth [success=1 default=bad] pam_unix.so
auth [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900
auth sufficient pam_faillock.so authsucc audit deny=5 unlock_time=900
默认值TMOUT确定用户的shell超时时间。TMOUT值以秒为单位。编辑/etc/bashrc和/etc/profile文件(以及系统上支持的任何其他Shell的适当文件),并添加或编辑任何umask参数,如下所示:
TMOUT=600
PermitEmptyPasswords参数指定SSH服务器是否允许登录具有空密码字符串的帐户。编辑/etc/ssh/sshd_config文件以设置参数,如下所示:
PermitEmptyPasswords no
umask默认值确定用户创建的文件的权限。创建文件的用户可以通过chmod命令自行决定使其他人可以读取其文件和目录。编辑/etc/bashrc,/etc/profile和/etc/profile.d/*.sh文件(以及系统上支持的任何其他Shell的适当文件),并添加或编辑umask参数,如下所示:
umask 027
备注(修复完后运行以下命令以确保是否已完全修复)
grep -H "umask" /etc/bashrc
grep -H "umask" /etc/profile
grep -H "umask" /etc/profile.d/*.sh
如果umask配置不为027的,需全部修改为027或更严格
MaxAuthTries参数指定每个连接允许的最大身份验证尝试次数。登录失败次数达到设置参数一半时,错误消息将写入syslog文件,详细说明登录失败。编辑/etc/ssh/sshd_config文件以设置参数,如下所示:
MaxAuthTries 4
# 修改完成后重启sshd生效
systemctl restart sshd
这两个选项ClientAliveInterval和ClientAliveCountMax控制SSH会话超时。当ClientAliveInterval变量被设置,对指定的时间长度没有活动的SSH会话被终止。当ClientAliveCountMax变量被设置,sshd将在每一个客户端发送活动消息ClientAliveInterval的时间间隔。当连续发送的客户端活动消息数没有客户端响应时,ssh会话将终止。编辑/etc/ssh/sshd_config文件以设置参数:
ClientAliveInterval 300
ClientAliveCountMax 0
secure ICMP重定向与ICMP重定向相同,只是它们来自默认网关列表上列出的网关。在/etc/sysctl.conf或/etc/sysctl.d/*文件中设置以下参数:
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
运行以下命令来设置活动的内核参数:
# sysctl -w net.ipv4.conf.all.secure_redirects=0
# sysctl -w net.ipv4.conf.default.secure_redirects=0
# sysctl -w net.ipv4.route.flush=1
RDS协议是一种传输层协议,旨在提供群集节点之间的低延迟,高带宽通信。它是由Oracle Corporation开发的。编辑或创建文件/etc/modprobe.d/CIS.conf并添加以下行:
install rds /bin/true
SSH支持两种不同且不兼容的协议:SSH1和SSH2。 SSH1是原始协议,受安全问题的影响。 SSH2更先进,更安全。编辑/etc/ssh/sshd_config文件以设置参数,如下所示:
Protocol 2
编辑/etc/pam.d/password-auth和/etc/pam.d/system-auth文件,以符合站点策略:
password requisite pam_pwquality.so try_first_pass retry=3
编辑/etc/security/pwquality.conf以添加或更新以下设置以符合站点策略:
minlen = 14
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
# 生成证书,建议添加密码,出现在/root/~/.ssh目录下 ssh-keygen -t rsa # 导入公钥 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys # 设置权限 chown -R 0700 ~/.ssh chown -R 0644 ~/.ssh/authorized_keys chown -R ifshow:ifshow /home/ifshow # 设置策略 vi /etc/ssh/sshd_config RSAAuthentication yes StrictModes no PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys # 重启服务 systemctl restart sshd # 将id_rsa复制到远程连接的客户端电脑 # 配置通过证书ssh连接 # 连接成功后继续去服务器修改策略 vi /etc/ssh/sshd_config PasswordAuthentication no # 关闭通过密码登录 # 重启服务 systemctl restart sshd # 完成
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。