当前位置: 首页 > news >正文

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可以秒连接了

http://www.cnnetsun.cn/news/40006.html

相关文章:

  • 46、Python 网络编程与套接字全解析
  • 微信自动答题小工具终极指南:Python开发者的效率利器
  • 实战指南:从零开始掌握Langflow自定义组件开发
  • FastAPI性能优化深度解析:从基础到高级实践
  • 5分钟掌握wandb:解决机器学习实验混乱的终极指南
  • ISO/IEC 27005:2022完整教程:信息安全风险管理终极指南
  • 巫妖易语言+js逆向+安卓逆向hook培训教程
  • 5个实用技巧彻底解决PhpSpreadsheet内存不足问题
  • JMeter接口测试之文件上传
  • 从零开始:5步搞定BDD100K数据集训练,新手也能轻松上手![特殊字符]
  • java计算机毕业设计陕西理工大学返校管理系统 高校学生返校审批与宿舍信息一体化平台 基于Vue+SpringBoot的校园返校及住宿服务系统
  • 36亿参数撬动韩国AI生态:Kakao Kanana-1.5-v-3b-instruct多模态模型深度解析
  • 如何用AI快速修复老旧视频?SeedVR2-7B让1080P修复仅需0.8秒
  • 轻量级AI新范式:重新定义企业智能部署的终极方案
  • OpenMower测试实战:从零到一的智能割草机器人验证指南
  • MotionGPT终极指南:用语言模型生成人类运动的完整方法
  • TL494 BUCK电路完整指南:从原理到PCB制作的实战教程
  • ZVT量化框架模块化设计终极指南:5步快速上手智能交易系统
  • 10、深入理解SELinux类型规则与Apol工具的使用
  • 视频生成技术革命:LightVAE如何重塑创作效率边界
  • WordPress 专业建筑行业公司网站主题模板 – Constructo v5.0.0
  • noVNC剪贴板同步完全指南:解决远程复制粘贴难题
  • FusionSpec投机推理:让大模型推理速度飙升的优化策略
  • WPS VBA 7.1插件技术实现与自动化办公解决方案深度解析
  • Qwen3-VL-4B-Instruct-FP8:如何用40亿参数重塑企业级多模态AI生态?
  • Logto身份认证系统入门指南:从零构建安全登录体系
  • 【Java毕设全套源码+文档】基于Java的教学评价管理系统的设计与实现(丰富项目+远程调试+讲解+定制)
  • 【Java毕设全套源码+文档】基于Java的教务管理系统设计与实现(丰富项目+远程调试+讲解+定制)
  • 7、自定义报告处理器:Puppet 中的数据处理与监控
  • 8、Puppet 报告处理与 PuppetDB 探索