解决ssh登录过慢问题
1.首先打开debug,看看慢在哪里
[root@BC-NFS1 ~]# ssh -v root@192.168.102.41 -p 22
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to 192.168.102.41 [192.168.102.41] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 52:28:48:e7:49:2a:c3:56:78:c1:ea:78:58:56:ab:27
debug1: Host '192.168.102.41' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0) debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0) debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
root@192.168.102.41's password:
2.修改配置文件
在被远程登录的服务器上执行以下操作
vi /etc/ssh/sshd_config
UseDNS no
看到我的debug信息有这些,说明还需要修改/etc/ssh/sshd_config
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
vi /etc/ssh/ssh_config
GSSAPIAuthentication no
3.重启服务
systemctl restart sshd
有的人的问题出在输入密码之后要等待10-20s
root@x.x.x.x's password:
debug1: Authentication succeeded (password).
Authenticated to x.x.x.x ([x.x.x.x]:xx).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
通过日志可以发现,密码的验证没有损耗时间,已经正确验证通过Authentication succeeded (password)
哪么到底是什么原因导致的速度这么慢?
打开服务器的系统日志,查看
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 closed for user root
sshd[12689]: userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes [preauth]
sshd[12689]: Accepted password for root from x.x.x.x port 52866 ssh2
sshd[12689]: pam_unix(sshd:session): session opened for 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可以秒连接了
解决ssh登录过慢问题的更多相关文章
- 解决SSH登录用户执行的命令部分环境变量参数不生效的问题
问题概况 linux机器在/etc/profile配置完成环境变量后,SSH到目标机器执行命令,但是获取不到已配置的环境变量值. 例如场景: 在/etc/profile配置了http代理 export ...
- 解决ssh登录Host key verification failed
使用SSH登录某台机器,有时因为server端的一些变动,会出现以下信息: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: R ...
- 如何解决SSH登录Solaris主机速度慢的问题
SSH登录速度慢可能有多种原因. 1. 与DNS有关 缺省情况下,当客户端用SSH登录solaris服务器时,服务器会试图反向解析客户端的IP 地址(即把IP地址解析成机器名).如果Solaris系统 ...
- 解决 ssh 登录到ubuntu server 慢的问题
最近在服务器上使用ubuntu系统,服务器上开启sshd服务,在客户端处使用ssh登录到服务器的时候出现卡顿的现象. 在网上搜索了解决方案,主要是: 1. 修改服务器的 /etc/ssh/sshd_c ...
- 解决ssh登录慢,等待时间长的问题
有时候在ssh远程登录到其他主机上时发现登录时间太长,经过亲自测试,发现主要有两个问题会导致ssh登录慢: 1.使用了dns反查,这样的话当ssh某个IP时,系统会试图通过DNS反查相对应的域名,如果 ...
- 解决ssh登录很慢的问题以及jumpserver登录主机出现:Authentication timeout
一.问题 登录ssh输入用户名后,等待很长时间20-30秒左右才显示输入密码提示框,从而导致通过jumpserver堡垒机登录主机时,报错:Authentication timeout Opt> ...
- 解决ssh登录后闲置时间过长而断开连接
++++++++++++++++++++++++++++ #!/usr/bin/env bash password_5="Uxxx7"host_5="129.x.x.1 ...
- Mac 解决SSH登录服务器终端乱码
一.Mac自带的终端 ssh 连接Linux 乱码,可用如下方法解决 终端 --> 偏好设置 --> 描述文件 --> 高级 --> 设为GBK 即可 二.secureCRT ...
- [转]解决ssh登录后闲置时间过长而断开连接
本文转自: 转载自博客园wanghetao的博客 我们通过终端连接服务器时,当鼠标和键盘长时间不操作,服务器就会自动断开连接,我们还的需要重新连接,感觉很麻烦,总结一下解决此问题的方法 方法一 修改/ ...
随机推荐
- HDU1507二分图
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- Qt -------- 容器类
QVector(数组).QLinkedList(链表).QMap(映射表).QHash(哈希表).QQueue(队列) QHash遍历举例: 法1: QThread& ThreadHandle ...
- Rsync+inotify自动同步数据
一.简介 随着应用系统规模的不断扩大,对数据的安全性和可靠性也提出的更好的要求,rsync在高端业务系统中也逐渐暴露出了很多不足. 首先,rsync在同步数据时,需要扫描所有文件后进行比对,进行差量传 ...
- DIV CSS display(block,inline,none)的属性教程
display:inline.block.inline-block的区别 display:block就是将元素显示为块级元素. block元素的特点是: 总是在新行上开始: 高度,行高以及顶和底边距都 ...
- redis linux下的开机启动
redis linux下的环境搭建 http://www.cnblogs.com/zsg88/p/8321644.html 安装完redis-4.0.1后设置linux开机自启动. 1.在re ...
- 【uva12232/hdu3461】带权并查集维护异或值
题意: 对于n个数a[0]~a[n-1],但你不知道它们的值,通过逐步提供给你的信息,你的任务是根据这些信息回答问题: I P V :告诉你a[P] = V I P Q V:告诉你a[P] XOR a ...
- LTC 钱包部署
基础环境 系统: CentOS 7.x nodejs: v4.6.0 zeromq: 4.x 安装nodejs + zeromq 基础依赖 yum install -y gcc make gcc-c+ ...
- 【转】IOS版本自定义字体步骤
本文转载自:http://quick.cocoachina.com/wiki/doku.php?id=ios%E7%89%88%E6%9C%AC%E4%BD%BF%E7%94%A8%E8%87%AA% ...
- 使用idea+Tomcat搭建servlet服务器
1.使用java 搭建一个简单的Servlet 服务器 https://blog.csdn.net/qq_35164169/article/details/76146655
- mysql 复制表结构 / 从结果中导入数据到新表
这只会复制结构: mysql> create table a like mysql1; Query OK, 0 rows affected (0.03 sec) mysql> desc a ...