解决方案: scp/ssh 的登陆提示很慢 (Linux)
2016-03-23 17:22
691 查看
看着用 windows 的 scp 命令很快很是羡慕. 这个问题让我实实郁闷了好几天. 在 Linux 下不管是用 ssh 还是用 scp, 连接速度都很慢 (登陆提示框的弹出时间).
确切地讲, 每次的登陆连接平均消耗了 30 秒!
言归正传. 如何找出究竟是什么导致了 ssh 或是 scp 的登陆很慢? 如何修复该所谓的登陆 "慢" 或 "延迟"?
今天 Google 了一下, 很快就有了解决方案. :-)
你也 google 了吧? :-)
你可以用 -v 选项确认你的情况. 例如, 下面是 ssh 的详细登陆过程:
解决方案
就我所遇到的情况来看, 显然是要把 GSSAPI 禁用. 以下是三种可行的方式:
[注] 该解决方案是在客户端 OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 下测试并通过的.
1. 连接时用命令指定:
2. 在 ssh 客户端程序的配置文件里显式禁用 GSSAPI 认证. 如, 编辑 /etc/ssh/ssh_config 文件, 添加或修改使其有如下一行:
3. 在用户根目录下的 .ssh 目录下创建一个 config 文件. 如, 编辑 /home/cherry/.ssh/config (如果该文件不存在, 则创建之), 添加选项:
[注] A. /etc/ssh/ssh_config 是全局配置文件, 对其进行的修改会影响所有使用 ssh 客户端的系统用户.
B. /home/cherry/.ssh/config 是只会影响用户 xcl 的本地 ssh 客户端配置文件. 该文件的所有配置参数会覆盖全局配置文件的相同配置参数.
在禁用 GSSAPI 后, ssh 的登陆提示 "回归" 正常了:
可见, 该过程已经不再使用 GSSAPI 了. 速度也大大提高了.
确切地讲, 每次的登陆连接平均消耗了 30 秒!
言归正传. 如何找出究竟是什么导致了 ssh 或是 scp 的登陆很慢? 如何修复该所谓的登陆 "慢" 或 "延迟"?
今天 Google 了一下, 很快就有了解决方案. :-)
你也 google 了吧? :-)
什么导致了 scp 和 ssh 的登陆提示速度下降
就我自身所遇到的情况来看, 这些延迟绝大部分是 GSSAPI 的认证功能导致的!你可以用 -v 选项确认你的情况. 例如, 下面是 ssh 的详细登陆过程:
cherry@cherry:~$ ssh -v cherry@59.151.47.49 ... ... 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 No credentials cache found debug1: Unspecified GSS failure. Minor code may provide more information No credentials cache found debug1: Unspecified GSS failure. Minor code may provide more information debug1: Next authentication method: publickey debug1: Trying private key: /home/cherry/.ssh/identity debug1: Trying private key: /home/cherry/.ssh/id_rsa debug1: Trying private key: /home/cherry/.ssh/id_dsa debug1: Next authentication method: password cherry@59.151.47.49's password:
解决方案
就我所遇到的情况来看, 显然是要把 GSSAPI 禁用. 以下是三种可行的方式:[注] 该解决方案是在客户端 OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 下测试并通过的.
1. 连接时用命令指定:
ssh -o GSSAPIAuthentication=no cherry@59.151.47.49
2. 在 ssh 客户端程序的配置文件里显式禁用 GSSAPI 认证. 如, 编辑 /etc/ssh/ssh_config 文件, 添加或修改使其有如下一行:
GSSAPIAuthentication no
3. 在用户根目录下的 .ssh 目录下创建一个 config 文件. 如, 编辑 /home/cherry/.ssh/config (如果该文件不存在, 则创建之), 添加选项:
GSSAPIAuthentication no
[注] A. /etc/ssh/ssh_config 是全局配置文件, 对其进行的修改会影响所有使用 ssh 客户端的系统用户.
B. /home/cherry/.ssh/config 是只会影响用户 xcl 的本地 ssh 客户端配置文件. 该文件的所有配置参数会覆盖全局配置文件的相同配置参数.
在禁用 GSSAPI 后, ssh 的登陆提示 "回归" 正常了:
cherry@cherry:~$ ssh -v cherry@59.151.47.49 ... ... 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: publickey debug1: Trying private key: /home/cherry/.ssh/identity debug1: Trying private key: /home/cherry/.ssh/id_rsa debug1: Trying private key: /home/cherry/.ssh/id_dsa debug1: Next authentication method: password cherry@59.151.47.49's password:
可见, 该过程已经不再使用 GSSAPI 了. 速度也大大提高了.
相关文章推荐
- linux 安装 lrzsz
- Linux命令--- /dev/null和/dev/tty
- linux---正则表达式
- Linux升级openssh及问题总结
- linux命令---wc
- linux命令---head与tail
- 主要的中断下半部及其区别
- Linux 内核配置机制(make menuconfig、Kconfig、makefile)讲解
- linux 下共享内存shm详解
- linux中fork()函数详解
- 几个常用的Linux监控脚本
- Linux source code Makefile分析
- linux系统中关于中断、异常、系统调用、陷阱等概念的解析
- ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
- Linux内核协议栈(3) 刨根问底socket调用
- 在 Android 中执行 Linux 终端命令
- Linux内核分析——分析system_call中断处理过程
- Linux常用命令大全(1)--系统,文件
- Linux下的AudoCAD替代软件
- CentOS下phpMyAdmin安装