隐藏SSH登录的bannner 默认为空
修改ssh的版本信息
# cp /usr/sbin/sshd /usr/sbin/sshd.bak
# strings /usr/sbin/sshd | grep 6.6
# sed -i 's/OpenSSH_6.6/OpenSSH_8.8/g' /usr/sbin/sshd
# service restart sshd
SSH使用版本2
# Protocol = 2
不允许root远程登录;
# PermitRootLogin no #禁止root登录SSH
不允许空密码
不允许rlogin、rhost登录
# IgnoreRhosts =yes;
配置并限制允许登录的IP地址与账户
# cat /etc/ssh/sshd_config显示控制可访问的IP和账户
AllowUsersuser1 user2
或#more /etc/hosts.allow
sshd:10.0.0.1:allow
更改默认监听端口,设置非标准端口
密码重试次数
MaxAuthTries=6
Configure Idle Log Out Timeout Interval
ClientAliveInterval 300
ClientAliveCountMax 0
设定空闲会话超时时长;
Firewall SSH Port # 22
使用iptables设置ssh服务安全访问策略Use Log Analyzer
记录好日志,经常做日志分析禁用ssh弱加密
# vim /etc/ssh/sshd_config
Ciphers aes192-ctr,aes256-ctr,arcfour256
MACs hmac-sha1,hmac-ripemd160
#查看命令
ssh -vv -oCiphers=aes128-cbc,3des-cbc,blowfish-cbc <serverIP>
#验证:ssh -vv -o Ciphers=aes192-ctr,aes256-ctr serverIP
会提示passwd登录证明已经匹配
ssh服务的最佳实践:
1、不要使用默认端口;
2、禁止使用protocol version 1;
3、限制可登录用户;
4、设定空闲会话超时时长;
5、利用防火墙设置ssh访问策略;
6、仅监听特定的IP地址;
7、基于口令认证时,使用强密码策略;
8、使用基于密钥的认证;
9、禁止使用空密码;
10、禁止root用户直接登录;
11、限制ssh的访问频度和并发在线数;
12、做好日志,经常分析;
转载于:https://blog.51cto.com/redone/1952688