如何修复子系统请求在通道0上失败
How to fix subsystem request failed on channel 0

原始链接: https://blog.x-way.org/Linux/2025/11/06/How-to-fix-subsystem-request-failed-on-channel-0.html

2025年11月06日 - 21:11 今天我在尝试使用scp传输文件时,遇到了以下错误: # scp a.txt user@somehost:/tmp/b.txt subsystem request failed on channel 0 scp: Connection closed 这个神秘的错误信息来自于OpenSSH 9版本引入的一个默认配置更改。默认情况下,它现在使用sftp协议进行文件传输,不再使用原始的scp协议。因此,对于只支持原始scp而不支持sftp子系统的host,文件传输将出现上述错误。 幸运的是,可以使用-O参数来选择原始的scp协议,然后传输就会成功: # scp -O a.txt user@somehost:/tmp/b.txt

## OpenSSH “子系统请求失败”问题 一篇 Hacker News 的讨论集中在通过 OpenSSH 使用 `scp` 时遇到的“子系统请求失败”错误。 问题的核心在于一个注重安全的的设计选择:如果 `sftp` 子系统失败,OpenSSH 不会自动回退到 `scp`。 虽然可以存在回退机制,但 `scp` 和 `sftp` 之间 shell 扩展差异相关的潜在安全漏洞阻止了这一点。 `scp` 依赖于远程服务器上的 shell 执行,存在风险,而 `sftp` 使用独立的协议层。 OpenSSH 开发者正在积极淘汰 `scp`,转而支持更现代和安全的替代方案,如 `sftp` 和 `rsync`。 用户也批评了错误信息本身,认为它没有帮助,并且缺乏明确的解决方案指导。 一种常见的解决方法是使用 `-O` 标志,但许多人提倡改进错误信息,并可能提供可配置的回退选项。
相关文章

原文

Today I got greeted by the following error when I was trying to scp some file.

# scp a.txt user@somehost:/tmp/b.txt
subsystem request failed on channel 0
scp: Connection closed

This cryptic error message comes from a default config change that OpenSSH introduced in version 9.
By default it now uses the sftp protocol for transfering files and no longer the original scp protocol.
Thus for hosts which do not support the sftp subsystem, but only the original scp, the file transfer fails with the above error.

Luckily there is the -O parameter which can be used to select the original scp protocol, and the transfer then succeeds:

# scp -O a.txt user@somehost:/tmp/b.txt
联系我们 contact @ memedata.com