SSH安全配置
配置基于CentOS7
配置文件: #
/etc/ssh/sshd_config
设定文件权限#
chown root:root /etc/ssh/sshd_config chmod og-rwx /etc/ssh/sshd_config
配置文件#
#### 这里设置了禁止root登录,请确保一定提前建立好登录用户
# 设定日志级别 LogLevel INFO # 用户登录失败,在切断连接前服务器需要等待的时间,单位为秒 LoginGraceTime 60 # 不允许root登录 PermitRootLogin no # 密码验证失败允许次数 MaxAuthTries 4 # 这是通过在RSA认证成功后再检查 ~/.rhosts 或 /etc/hosts.equiv 进行认证的。出于安全考虑,建议使用默认值"no"。 HostbasedAuthentication no # 是否在 RhostsRSAAuthentication 或 HostbasedAuthentication 过程中忽略 .rhosts 和 .shosts 文件。 不过 /etc/hosts.equiv 和 /etc/shosts.equiv 仍将被使用。推荐设为默认值"yes"。 IgnoreRhosts yes # 不允许空密码登录 PermitEmptyPasswords no # 禁止下x11转发 X11Forwarding no # 指定是否允许 sshd(8) 处理 ~/.ssh/environment 以及 ~/.ssh/authorized_keys 中的 environment= 选项。 默认值是"no"。如果设为"yes"可能会导致用户有机会使用某些机制(比如LD_PRELOAD)绕过访问控制,造成安全漏洞 PermitUserEnvironment no # ssh会话存活时间 ClientAliveInterval 300 # 到达会话存活时间,发送alive给服务器的次数 ClientAliveCountMax 0 # 使用ssh协议2 Protocol 2 # 只使用经批准的MAC算法 MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com # 允许的用户通过ssh登录 AllowUsers redhat # 允许的组通过ssh登录 AllowGroups root redhat
# 用户登陆前的提示信息文件路径
Banner /etc/issue.net
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
2017-06-11 commons-beanutils的使用