news 2026/6/14 22:53:02

ssh连接慢的原因调查及解决方案

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
ssh连接慢的原因调查及解决方案

1.通过[-v]参数,查看ssh连接的具体过程
deMacBook-Pro:~ yyq$ssh -v root@x.x.x.x -p xx
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data/etc/ssh/ssh_config
debug1:/etc/ssh/ssh_config line 21: Applying optionsfor *
debug1: Connecting to x.x.x.x [x.x.x.x] port xx.
debug1: Connection established.
debug1: identityfile /Users/yyq/.ssh/id_rsa type 1
debug1: key_load_public: No suchfile or directory
debug1: identityfile /Users/yyq/.ssh/id_rsa-cert type -1
debug1: identityfile /Users/yyq/.ssh/id_dsa type 2
debug1: key_load_public: No suchfile or directory
debug1: identityfile /Users/yyq/.ssh/id_dsa-cert type -1
debug1: key_load_public: No suchfile or directory
debug1: identityfile /Users/yyq/.ssh/id_ecdsa type -1
debug1: key_load_public: No suchfile or directory
debug1: identityfile /Users/yyq/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No suchfile or directory
debug1: identityfile /Users/yyq/.ssh/id_ed25519 type -1
debug1: key_load_public: No suchfile or directory
debug1: identityfile /Users/yyq/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility modefor protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to x.x.x.x:xx as'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:HictrRpAs7Yv495dDLNqHsFCNKXVACpX9FWUnNVenZU
debug1: Host'[x.x.x.x]:xx' is known and matches the ECDSA host key.
debug1: Found keyin /Users/yyq/.ssh/known_hosts:38
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that cancontinue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key:/Users/yyq/.ssh/id_rsa
debug1: Authentications that cancontinue: publickey,password
debug1: Offering DSA public key:/Users/yyq/.ssh/id_dsa
debug1: Authentications that cancontinue: publickey,password
debug1: Trying private key:/Users/yyq/.ssh/id_ecdsa
debug1: Trying private key:/Users/yyq/.ssh/id_ed25519
debug1: Next authentication method: password
root@x.x.x.x's password:

首先观察有没有出现耗时的操作?
2.打开服务器的系统日志,查看错误日志
tail -f/var/log/auth.log
sshd[12642]: pam_systemd(sshd:session): Failed to create session: Connection timed out
dbus[617]: [system] Failed to activate service'org.freedesktop.login1': timed out
sshd[12642]: Received disconnect from x.x.x.x port 52856:11: disconnected by user
sshd[12642]: Disconnected from x.x.x.x port 52856
sshd[12642]: pam_unix(sshd:session): session closedfor user root
sshd[12689]: userauth_pubkey: keytype ssh-dss notin PubkeyAcceptedKeyTypes [preauth]
sshd[12689]: Accepted passwordfor root from x.x.x.x port 52866 ssh2
sshd[12689]: pam_unix(sshd:session): session openedfor user root by (uid=0)
sshd[12689]: pam_systemd(sshd:session): Failed to create session: Connection timed out
dbus[617]: [system] Failed to activate service'org.freedesktop.login1': timed out

从日志中可以看到[system] Failed to activate service ‘org.freedesktop.login1’: timed out的错误,大致意思如下:
dbus的服务重启后,systemd-logind服务没有重启导致,可以查看systemctl status systemd-logind的状态,解决方法就是重启该服务 systemctl restart systemd-logind
重启systemd-logind服务后,发现ssh可以秒连接了

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/15 7:33:56

终极指南:如何解决LLM-Cookbook项目PDF文档版本管理难题

终极指南&#xff1a;如何解决LLM-Cookbook项目PDF文档版本管理难题 【免费下载链接】llm-cookbook 面向开发者的 LLM 入门教程&#xff0c;吴恩达大模型系列课程中文版 项目地址: https://gitcode.com/datawhalechina/llm-cookbook LLM-Cookbook作为面向开发者的LLM入门…

作者头像 李华
网站建设 2026/6/12 15:37:56

CNI容器网络安全实战:从漏洞防护到持续监控的完整指南

CNI容器网络安全实战&#xff1a;从漏洞防护到持续监控的完整指南 【免费下载链接】cni Container Networking 是一个开源项目&#xff0c;旨在实现容器网络和网络应用的高效编排和管理。 * 容器网络管理、网络应用编排和管理 * 有什么特点&#xff1a;基于 Kubernetes 和容器技…

作者头像 李华
网站建设 2026/6/15 4:35:07

保姆级的MySQL执行计划(Explain)解读

什么是执行计划在查询语句开头添加explain关键字&#xff0c;然后执行查询&#xff0c;就可以看到执行计划。执行计划代表这个SQL执行的过程&#xff0c;MySQL解释器将如何处理该SQL&#xff0c;通过对执行计划的分析&#xff0c;方便做SQL优化。数据准备当前数据库版本为8.0.4…

作者头像 李华
网站建设 2026/6/14 14:29:45

Grafika Android图形处理终极使用指南:5分钟快速上手

Grafika Android图形处理终极使用指南&#xff1a;5分钟快速上手 【免费下载链接】grafika Grafika test app 项目地址: https://gitcode.com/gh_mirrors/gr/grafika Grafika是Google官方推出的Android图形处理测试应用&#xff0c;专门用于展示和测试Android平台的Open…

作者头像 李华
网站建设 2026/6/15 18:31:49

47、Python 互联网应用编程指南

Python 互联网应用编程指南 1. Python 网络库模块与 FTP 协议 在 Python 编程中,网络相关的库模块在 Python 2 和 3 之间存在显著差异。为了面向未来,我们主要关注 Python 3 的库组织方式,不过不同版本的库模块功能基本相同。接下来,我们先探讨 ftplib 模块,它实现了 F…

作者头像 李华
网站建设 2026/6/15 0:51:27

40亿参数重构:Qwen3-Embedding如何优化企业语义检索成本结构

在人工智能技术快速迭代的今天&#xff0c;企业级语义检索系统正面临前所未有的成本压力与性能挑战。据行业调研数据显示&#xff0c;超过83%的企业在构建检索增强生成(RAG)系统时&#xff0c;仍依赖昂贵的商业API服务&#xff0c;仅嵌入向量生成这一项&#xff0c;每百万次调用…

作者头像 李华