如何加快我太慢的 ssh 登录?

tsh*_*ang 49 ssh

运行ssh user@hostname需要大约 30 秒。这是场景:

  • 这是本地 LAN 上的 VM
  • Windows 和 Mac 机器获得即时登录
  • 正在使用 Debian,我可以使用 Ubuntu 机器进行复制
  • 有人使用 Ubuntu 说登录我的机器(本地 LAN)也是即时的
  • 使用主机名 IP 地址大约需要一半的时间(~15 秒)

[更新]

使用ssh -vvv user@hostname,这是它等待最多的地方:

debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
Run Code Online (Sandbox Code Playgroud)

然后在这里等一下:

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found
Run Code Online (Sandbox Code Playgroud)

小智 34

编辑您的“ /etc/ssh/ssh_config ”并注释掉这些行:

GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
Run Code Online (Sandbox Code Playgroud)

或者,在 SSH 配置 ( ~/.ssh/config)中包含以下内容也有效:

GSSAPIAuthentication no
Run Code Online (Sandbox Code Playgroud)

  • +1 不错的答案!(1) ssh登录连接占用光标闪烁7次的时间是正常速度吗?(2) 为什么通过注释掉`GSSAPIAuthentication yes` 和`GSSAPIDelegateCredentials no` 会起作用?@Tshepang (3认同)
  • 大多数 OpenSSH 版本中 GSSAPIAuthentication 的默认设置为“no”,但某些发行版在 sshd_config 和 ssh_config 文件中将其设置为“yes”。如果您不需要/使用它,它会减慢连接/身份验证握手的速度。 (2认同)

Ear*_*rlz 33

我遇到了这个问题,并通过关闭 SSH 中的反向 DNS 解析来解决它。

因此,在sshd_config服务器改变这样的:

 #UseDNS yes
Run Code Online (Sandbox Code Playgroud)

对此:

UseDNS no
Run Code Online (Sandbox Code Playgroud)

  • @Tshe 嗯,奇怪。我在 SSH 上遇到的唯一速度问题是由于这个。 (2认同)

Chr*_*ian 7

您是否已验证您的 DNS 设置?

尝试设置mdns off/etc/host.conf

这禁用了 mdns 分辨率并帮助了我很多。

编辑:

gentoo 似乎处理这个有点不同。要禁用多播 DNS 查找,您必须更改文件/etc/nsswitch.conf.
应该有类似的东西:

hosts:          files mdns
Run Code Online (Sandbox Code Playgroud)

将其更改为:

hosts:          files dns
Run Code Online (Sandbox Code Playgroud)