Files
Linux/问题记录/Xshell连接Centos7-2009缓慢.md
offends 74bca24ec4
All checks were successful
continuous-integration/drone Build is passing
新增文档
2025-11-06 20:09:07 +08:00

937 B
Raw Blame History

本文作者:丁辉

Xshell连接Centos7-2009缓慢

问题原因

UseDNS yes 用于 SSH 连接时的 DNS 反向解析SSH 一直检测 DNS 导致连接缓慢。

工作原理

默认行为 (UseDNS yes)

# SSH连接建立过程
1. 客户端发起连接 → 服务器
2. 服务器获取客户端IP → 执行DNS反向解析
3. DNS查询客户端IP的主机名 → 可能耗时
4. 然后执行DNS正向解析验证 → 可能再次耗时
5. 最后才进行身份认证

禁用后 (UseDNS no)

# SSH连接建立过程
1. 客户端发起连接 → 服务器
2. 服务器直接进行身份认证
3. 跳过所有DNS解析步骤

解决方案

  1. 修改 SSH 配置文件

    vi /etc/ssh/sshd_config
    

    修改为如下内容

    UseDNS no
    
  2. 重启服务

    systemctl restart sshd
    
  3. 再次重新连接,缓慢速度已解决