1. 更改默认端口
2. 限制允许登录的用户
方法一:使用/etc/hosts.allow和/etc/hosts.deny文件
sshd:允许的IP地址
sshd:ALL
systemctl restart sshd
systemctl status sshd
方法二:使用/etc/ssh/sshd_config中的AllowUsers或DenyUsers指令
AllowUsers [email protected]#仅允许10.10.68.38的root用户访问
systemctl restart sshd
systemctl status sshd
3. 配置防火墙规则
合理配置防火墙,仅允许特定IP地址或范围内的设备连接到SSH端口。
添加允许特定IP地址连接到新SSH端口的防火墙规则:
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.10.68.38" port port="2222" protocol="tcp" accept'
firewall-cmd --reload
原文始发于微信公众号(网络个人修炼):安全加固:轻松限制SSH访问的方法
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论