news 2026/7/8 12:46:12

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/7/7 12:39:14

KoNLPy终极指南:快速掌握韩语自然语言处理

KoNLPy终极指南&#xff1a;快速掌握韩语自然语言处理 【免费下载链接】konlpy Python package for Korean natural language processing. 项目地址: https://gitcode.com/gh_mirrors/ko/konlpy 想要轻松处理韩语文本数据吗&#xff1f;KoNLPy作为Python生态中最强大的韩…

作者头像 李华
网站建设 2026/7/8 5:27:01

青龙面板自动化脚本库:100+实用工具全面解析

在当今数字化时代&#xff0c;自动化已成为提升效率的关键。青龙面板作为最受欢迎的定时任务管理平台&#xff0c;结合QLScriptPublic脚本库&#xff0c;为用户提供了前所未有的自动化体验。这个开源项目汇集了100多个精心设计的脚本&#xff0c;覆盖了日常生活中的各种自动化需…

作者头像 李华
网站建设 2026/7/2 15:54:10

龙芯2K0300开发板:嵌入式开发的创新解决方案

在嵌入式开发领域&#xff0c;开发者经常面临硬件接口不足、扩展能力有限、调试过程繁琐的挑战。龙芯2K0300开发板系列通过创新的硬件设计和丰富的功能模块&#xff0c;为开发者提供了完善的解决方案。本文将从实际问题出发&#xff0c;深入解析这款开发板如何应对嵌入式开发中…

作者头像 李华
网站建设 2026/7/7 3:54:12

深度解析so-vits-svc配置参数:从问题诊断到性能调优的完整指南

当你面对so-vits-svc模型训练效果不理想时&#xff0c;是否曾感到无从下手&#xff1f;参数调整看似简单&#xff0c;实则暗藏玄机。本文将带你采用"问题诊断→解决方案→最佳实践"的三段式方法&#xff0c;系统掌握配置优化的核心技巧。 【免费下载链接】so-vits-sv…

作者头像 李华
网站建设 2026/7/7 12:41:31

Java小白求职互联网大厂:从Spring Boot到微服务的面试之旅

场景&#xff1a;Java小白超好吃面试互联网大厂 在一家知名互联网公司&#xff0c;面试官正准备开始对Java小白求职者超好吃进行面试。 第一轮&#xff1a;基础技术栈 面试官&#xff1a;你好&#xff0c;超好吃。你对Spring Boot了解吗&#xff1f;能否简单介绍一下它的核心功…

作者头像 李华
网站建设 2026/7/8 7:49:30

GPT-2编码器:从数据压缩到语言理解的桥梁设计

GPT-2编码器&#xff1a;从数据压缩到语言理解的桥梁设计 【免费下载链接】gpt-2 Code for the paper "Language Models are Unsupervised Multitask Learners" 项目地址: https://gitcode.com/GitHub_Trending/gp/gpt-2 在人工智能语言模型的发展历程中&…

作者头像 李华