Skip to content

SCP using SFTP fails with UNC paths #2221

Open
@jameymorris

Description

@jameymorris

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

With the current version of OpenSSH 9.5p1, I am unable to use SCP to or from a UNC path on a remote Windows machine. I was able to recreate this completely using a single computer (named dev01 in the expected behavior and actual behavior) using a shared folder on the local machine.

  1. Create a test folder (C:\Test) with a subfolder (scp_test). Inside the subfolder, create one or more files.
  2. In PS, run scp -r C:\Test\scp_test1 ${env:COMPUTERNAME}:\\${env:COMPUTERNAME}\Test\scp_test2

More information:

  • Using OpenSSH 8.9 works and 9.1 does not, so I assume this is because of the implementation change from SCP to SFTP.
  • Adding -O to force legacy SCP causes this command in OpenSSH 9.1 and OpenSSH 9.5 to function as expected. I assume this is not ideal and that using the SFTP implementation would be preferred.
  • I have tested on multiple systems with varying degrees of security implementation, and the failure mode is uniform.

Expected behavior

PS C:\Test> scp -r C:\Test\scp_test1 dev01:\\dev01\Test\scp_test2
test.txt                                                                          100%   14     0.0KB/s   00:00

Actual behavior

PS C:\Test> scp -r C:\Test\scp_test1 dev01:\\dev01\Test\scp_test2
C:\Program Files\OpenSSH\scp.exe: stat remote: Failure
C:\Program Files\OpenSSH\scp.exe: failed to upload directory C:/Test/scp_test1 to //dev01/Test/scp_test2

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

9.5p1

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions