【发布时间】:2019-11-21 02:58:04
【问题描述】:
当我尝试使用 ssh 在远程服务器上执行命令时,ssh 命令在exec request accepted 调试消息之后挂起,并最终超时。
失败的命令:ssh -v -v <username>@<server> uptime(也试过echo hello等)
debug1: Authentication succeeded (publickey).
Authenticated to <server> (<ip>:22).
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug2: fd 4 setting TCP_NODELAY
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug1: Sending command: uptime
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
然后它无限期地挂在那里。
但是,当我在没有命令的情况下 ssh 进入远程服务器时,我得到了一个交互式 shell,一切都很好。
成功的命令:ssh -v -v <username>@<server>
输出:
debug1: Authentication succeeded (publickey).
Authenticated to <server> (<ip>:22).
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug2: fd 4 setting TCP_NODELAY
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Welcome!
<prompt>%
...
有人知道为什么交互式会话会成功但命令执行不会成功吗?
几个月来一直困扰着我,因为我不能再使用 unison 来同步我的文件(它曾经可以工作)。非常感谢任何帮助。
【问题讨论】:
-
我不知道你的问题的答案,但我有一个想法。可能是您的 SSH 客户端或 SSH 服务器上的配置错误。在同一个服务器上尝试不同的客户端,然后在不同的服务器上尝试相同的客户端,让我们看看哪个有效。
-
一些类似的问题之前在stackoverflow上贴过:google.com/search?q=ssh+command+execution+hangs
-
这不是 SSH 配置问题 - 它从不同的客户端失败。服务器配置已为我锁定,但已由其他用户验证。这里发布的其他问题并不完全相同,我已经查看了它们。
标签: linux ssh remote-execution