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

51 lines
937 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 本文作者:丁辉
# Xshell连接Centos7-2009缓慢
## 问题原因
`UseDNS yes` 用于 SSH 连接时的 DNS 反向解析SSH 一直检测 DNS 导致连接缓慢。
## 工作原理
### 默认行为 (`UseDNS yes`)
```bash
# SSH连接建立过程
1. 客户端发起连接 → 服务器
2. 服务器获取客户端IP → 执行DNS反向解析
3. DNS查询客户端IP的主机名 → 可能耗时
4. 然后执行DNS正向解析验证 → 可能再次耗时
5. 最后才进行身份认证
```
### 禁用后 (`UseDNS no`)
```bash
# SSH连接建立过程
1. 客户端发起连接 → 服务器
2. 服务器直接进行身份认证
3. 跳过所有DNS解析步骤
```
## 解决方案
1. 修改 SSH 配置文件
```bash
vi /etc/ssh/sshd_config
```
修改为如下内容
```bash
UseDNS no
```
2. 重启服务
```bash
systemctl restart sshd
```
3. 再次重新连接,缓慢速度已解决