news 2026/4/16 17:51:32

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/4/16 10:40:15

12、Puppet模块使用与开发全解析

Puppet模块使用与开发全解析 1. Puppet Forge模块使用原则 在使用Puppet管理应用时,通常应用需要数据库来存储状态,以及用户凭证来访问它。以创建 cat_pictures 数据库并设置 greebo 用户账户访问为例,Puppet可以轻松完成这些操作,而 mysql 模块能让配置变得非常简…

作者头像 李华
网站建设 2026/4/16 10:40:38

【Java毕设源码分享】基于springboot+vue的健身房管理系统设计与实现(程序+文档+代码讲解+一条龙定制)

博主介绍&#xff1a;✌️码农一枚 &#xff0c;专注于大学生项目实战开发、讲解和毕业&#x1f6a2;文撰写修改等。全栈领域优质创作者&#xff0c;博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java、小程序技术领域和毕业项目实战 ✌️技术范围&#xff1a;&am…

作者头像 李华
网站建设 2026/4/16 12:14:53

300%性能飞跃:揭秘prompt-optimizer的Vue3架构优化实战

你是否曾经在提示词优化过程中遭遇界面卡顿、响应延迟的困扰&#xff1f;当处理复杂的长文本提示词时&#xff0c;是否感觉应用运行缓慢&#xff0c;甚至出现掉帧现象&#xff1f;今天&#xff0c;我们将深入解析prompt-optimizer项目的Vue3 TypeScript架构优化技巧&#xff0…

作者头像 李华
网站建设 2026/4/16 10:14:23

腾讯混元3D部件分割技术深度解析:从原理到实战的完整指南

腾讯混元3D部件分割技术深度解析&#xff1a;从原理到实战的完整指南 【免费下载链接】Hunyuan3D-Part 腾讯混元3D-Part 项目地址: https://ai.gitcode.com/tencent_hunyuan/Hunyuan3D-Part 你是否曾经面对复杂的3D模型&#xff0c;想要精确提取其中的特定部件却无从下手…

作者头像 李华
网站建设 2026/4/16 10:13:36

Wan2.1开源视频生成终极指南:消费级GPU上的720P革命

Wan2.1开源视频生成终极指南&#xff1a;消费级GPU上的720P革命 【免费下载链接】Wan2.1-FLF2V-14B-720P 项目地址: https://ai.gitcode.com/hf_mirrors/Wan-AI/Wan2.1-FLF2V-14B-720P 在AI视频生成技术快速发展的今天&#xff0c;高清视频生成的门槛一直是制约普通开发…

作者头像 李华
网站建设 2026/4/16 10:14:04

零基础创作完整歌曲:SongGeneration开源音乐模型终极指南

零基础创作完整歌曲&#xff1a;SongGeneration开源音乐模型终极指南 【免费下载链接】SongGeneration 腾讯开源SongGeneration项目&#xff0c;基于LeVo架构实现高品质AI歌曲生成。它采用混合音轨与双轨并行建模技术&#xff0c;既能融合人声与伴奏达到和谐统一&#xff0c;也…

作者头像 李华