您的位置:首页 > 职场人生

ssh登录服务器慢解决方法

2011-07-27 14:08 176 查看
遇到一台服务器ssh连接的时候很慢,大概要等半分钟。让人和郁闷.
网上的解决方法:
最为常见的原因是因为server的sshd会去DNS查找访问client IP的hostname,如果DNS不可用或者没有相关记录,就会耗费大量时间。
1、在server上/etc/hosts文件中把你本机的ip和hostname加入
2、在server上/etc/ssh/sshd_config文件中修改或加入UseDNS=no
重启sshd服务即可.

3. authentication gssapi-with-mic也有可能出现问题,在server上/etc/ssh/sshd_config文件中修改GSSAPIAuthentication no.
登录服务器的信息 ssh –v ip
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Unknown code krb5 195
debug1: Unspecified GSS failure.  Minor code may provide more information
Unknown code krb5 195
debug1: Unspecified GSS failure.  Minor code may provide more information
Unknown code krb5 195
debug1: Next authentication method: publickey
debug1: Trying private key: /home/gamemanager/.ssh/identity
按第三种方法竟然不生效,最好把客户端ip 加入hosts才算行. 不知道啥原因.
安全设置方面:
# 关于使用者抵挡的设定项目:
DenyUsers * # 设定受抵挡的使用者名称,如果是全部的使用者,那就是全部
# 挡吧!若是部分使用者,可以将该账号填入!例如下列!
DenyUsers test
DenyGroups test # 与 DenyUsers 相同!仅抵挡几个群组而已!
AllowUsers   test                #设置允许登录的用户.
# 关于 SFTP 服务的设定项目!
Subsystem       sftp    /usr/lib/ssh/sftp-server
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 服务器 server