总结sshd服务常用参数

sshd:openssh服务器守护进程。

服务器端:sshd

服务器端的配置文件: /etc/ssh/sshd_config

常用参数:

Port #生产建议修改
ListenAddress ip
LoginGraceTime 2m
PermitRootLogin yes #默认ubuntu不允许root远程ssh登录
StrictModes yes #检查.ssh/文件的所有者,权限等
MaxAuthTries 6 #pecifies the maximum number of authentication
attempts permitted per connection. Once the number of failures reaches half this
value, additional failures are logged. The default is 6.
MaxSessions 10 #同一个连接最大会话
PubkeyAuthentication yes #基于key验证
PermitEmptyPasswords no #空密码连接
PasswordAuthentication yes #基于用户名和密码连接
GatewayPorts no
ClientAliveInterval 10 #单位:秒
ClientAliveCountMax 3 #默认3
UseDNS yes #提高速度可改为no
GSSAPIAuthentication yes #提高速度可改为no
MaxStartups #未认证连接最大值,默认值10
Banner /path/file

#以下可以限制可登录用户的办法:
AllowUsers user1 user2 user3
DenyUsers user1 user2 user3
AllowGroups g1 g2
DenyGroups g1 g2

ssh服务的最佳实践:
(1)建议使用非默认端口
(2)禁止使用protocol version 1
(3)限制可登录用户
(4)设定空闲会话超时时长
(5)利用防火墙设置ssh访问策略
(6)仅监听特定的IP地址
(7)基于口令认证时,使用强密码策略,比如:tr -dc A-Za-z0-9_ < /dev/urandom | head -c 12|
xargs
(8)使用基于密钥的认证
(9)禁止使用空密码
(10)禁止root用户直接登录
(11)限制ssh的访问频度和并发在线数
(12)经常分析日志

 

posted @ 2022-05-06 10:05  海月如希  阅读(386)  评论(0编辑  收藏  举报