首页 > 编程知识 正文

ssh 连接很慢,linux ssh很慢

时间:2023-05-06 09:01:07 阅读:181190 作者:1031

环境:

服务器端操作系统: Ubuntu 15.04

客户端操作系统: windows 7

ssh客户端: putty 0.63

公司内部使用的编译服务器一直通过putty进行ssh连接。 每次连接时,输入用户面和密码(包括scp上传文件的操作)效率不高

lo ginas : useruser @ 192.168.1.230 ' s password :

在最近的服务器上,输入登录的用户名后,在出现password输入框之前,总是要等待10秒以上。 重新启动服务器也没用。

分析问题:使用ssh -v username@{ip_address}查看ssh连接日志

OpenSSH_6.6.1、OpenSSL1.0.1i6 aug 2014 debug 1: readingconfigurationdata/c/users/coffee/. ssh/config debug 13360 connecting to 192.1 port 22.debug 1: connection established.debug 1: identity file/c/users/coffee/. id _ RSA-cert type-1 debug 1: identity file/c/users/coffee/. ssh/id _ dsatype-1 debug 13360 identity filler id _ 1 coffee/. ssh/id _ ecdsatype-1 debug 1: identity file/c id _ ECD sa-cert type-1 debug 1: identity file/c/users/c id _ ed 25519 type-1 debug 13360 identity file id _ ed 25519-cert type-1 debug 1: enablingcompatibilitymodeforprotocol 2.0 ssh协议版本2.0, remotesoftwareversionopenssh _ 6.7p1Ubuntu-5 Ubuntu 1.4 debug 1: match : OpenSSH _ 6.7p1Ubuntu-5 Ubuntu 1.4 pat OpenSSH * compat0x 04000000 debug 1: ssh2_ msg _ kexinitsentdebug 1: ssh2_ msg _ kexinitreceiveddebug 13360 kex 3360 server-clie ee nt-server AES 128-CTR hmac-sha1-ETM @ OpenSSH.comnone debug 13360 sending ssh2_ msg _ kex _ ecdh _ reply 609 e : c 1:3 d 33607 d 33607 9:0 c :0 f 2:14 debug 1: host ' 192.168.1.230 ' isknownandmatchestheeecdsahostkey.ey uus kown _ hosts :7 debug 1: ssh _ ECD sa _ verify : signaturecorrectdebug 13360 ssh2_ msg _ newkeyssentdebug 13360 expex amingnotallowedbyserverdebug 1: ssh2_ msg _ service _ requestsentdebug 13360 ssh2_ service _ requestsentdebug 13360调试60公共密钥, password debug 1: nextauthenticationmethod : public key debug 1: offering RSA public key :/c/users/coffee/. ssh/id _ RSA debug 1: authenticationsthatcancontinue :公共密钥, password debug 1: trying private key :/c/users/coffee/. ssh/id _ DSA debug 1: trying private key 3360/c/users id c/users/coffee/. ssh/id _ ed 25519 debug 1: nextauthenticationmethod :密码为authenticationsthatcancontinue 3360

推测公钥认证方式太费时间,进行了公钥的构成。

利用ssh-keygen来生成公钥和私钥:id_rsd.pub以及id_rsa2。 如果将id_rsa.pub上传到服务器的. ssh目录下的: scpid _ RSA.pub user @ 192.168.1,并且此处放置了authorized_keys,则为纯ssh 另外,如果要使用putty,请使用以下步骤3.puttygen.exe生成要在putty中使用的私钥:运行puttygen.exe,然后选择菜单conversision。生成的id _ rssion 保存为id_rsa.ppk4.putty配置,并使用id_rsa.ppk左侧菜单中的Connection-SSH-Auth,右侧的privatekeyfileforauthentication为id_rsa.ppk 将Connection-Data的auto-login username配置为在登录服务器时无需再次输入用户名。 然后在session中输入您要访问的用户名进行连接,在标题栏菜单中选择Change Settings,保存当前的session配置,以后连接时无需密码即可连接到服务器

我以为配置结束就好了,但是还太晚了! 呃!

发生Using username后,仍然要等待约10s后才能自动连接。 根本问题还没有解决。 根据网络资料(http://www.linuxidc.com/Linux/2012-12/77144.htm ) ),连接缓慢可能是服务器端的sh配置问题。

查看服务器端的sshd-config时,没有配置UserDNS和GSSAPIAuthentication。 会不会是这两个构成的问题? 是什么?

手动添加UseDNS no并重新连接后,速度会变快,基本上不会等待连接。 看来默认情况下是UseDNS yes。

配置结束后,感觉使用变得极为顺畅,效率也提高了很多。 如果有时间的话试着安排一下,可以节约很多时间,所以强烈推荐。

参考资料:

解决SSH登录缓慢的问题

使用public/private key自动登录putty(ssh )

如何诊断和解决SSH连接缓慢问题

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。