subsystem request failed on channel 0 scp: Connection closed
Asked Answered
R

3

50

Running this command in the terminal:

scp -p -P 29418 [email protected]:hooks/commit-msg "jyei-erp/.git/hooks/"

returns the following error:

subsystem request failed on channel 0

scp: Connection closed

How can this be fixed?

Rounders answered 4/11, 2022 at 2:50 Comment(0)
J
105

Try -O as an option in your scp cmd, i.e.

scp -p -O -P 29418 [email protected]:hooks/commit-msg "jyei-erp/.git/hooks/"

Here is the documentation for the -O option:

-O Use the legacy 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.

Faced similar issue. This solution is from comments in github regarding this problem. For more details - https://github.com/PowerShell/Win32-OpenSSH/issues/1945

Jackstraws answered 28/11, 2022 at 7:45 Comment(3)
Adding the -O worked for me, although our gerrit server doesn't include it in the clone command by defaultHartfield
This issue is more related to newer versions of macOS rather than Gerrit.Jackstraws
Well this issue only happened to me after I upgraded to: OpenSSH_9.3p2, OpenSSL 3.1.3 19 Sep 2023, from ssh7 + openssl 1.1 or something along those lines. I am using Ubuntu on WSL. As far as I understand, the change was made with SSH 8.8 so you had to start using the -O beyond that version.Hartfield
K
36

Got the exact symptom on Linux. Giving -O fixed the issue. From scp manpage

     -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.
Kachine answered 16/2, 2023 at 6:44 Comment(0)
M
11

I was also facing this issue, adding -O flag fixed my issue as said by @pysbrg already above, final command:

scp -p -O -P 29418 [email protected]:hooks/commit-msg "jyei-erp/.git/hooks/"
Mat answered 21/3, 2023 at 12:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.