子系统请求在通道0上失败 scp: 连接关闭 - MacBook

29

能否请您帮个忙:

当我在终端中运行以下命令时: scp -p -P 29418 michealvern.genzola@192.168.0.122:hooks/commit-msg "jyei-erp/.git/hooks/"

它显示: subsystem request failed on channel 0 scp: Connection closed

请有经验的人士帮助我。

3个回答

63

在你的scp命令中尝试使用-O选项,例如:

scp -p -O -P 29418 michealvern.genzola@192.168.0.122:hooks/commit-msg "jyei-erp/.git/hooks/"

我曾经面临过类似的问题。这个解决方案来自于 Github 中有关此问题的评论。了解更多详情,请查看:https://github.com/PowerShell/Win32-OpenSSH/issues/1945


你更新了你的MacOS到Ventura吗?在MacOS更新后,这个问题似乎很常见。 - psybrg
加上 -O 对我来说起作用了,尽管我们的 Gerrit 服务器默认情况下不在克隆命令中包含它。 - undefined
这个问题更多与较新版本的macOS有关,而不是Gerrit。 - undefined
这个问题只发生在我升级到OpenSSH_9.3p2, OpenSSL 3.1.3 19 Sep 2023之后,之前使用的是ssh7 + openssl 1.1或类似版本。我在WSL上使用的是Ubuntu。据我所知,这个改变是在SSH 8.8版本中进行的,所以在那个版本之后你必须开始使用-O选项。 - undefined

22

在Linux上出现了完全相同的症状。使用-O修复了该问题。来自scp手册页

     -O      Use the original SCP protocol for file transfers instead of the SFTP protocol.  Forcing the use of the
             SCP protocol may be necessary for servers that do not implement SFTP, for backwards-compatibility for
             particular filename wildcard patterns and for expanding paths with a ‘~’ prefix for older SFTP servers.

8

我也遇到了这个问题,根据 @pysbrg 上面所说的,添加 -O 标志解决了我的问题,最终命令:

scp -p -O -P 29418 michealvern.genzola@192.168.0.122:hooks/commit-msg "jyei-erp/.git/hooks/"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接