Skip to content

upload gives no such file or directory for remotePath #1021

@evilC

Description

@evilC

Given the following code:

SCPFileTransfer xfer = client.newSCPFileTransfer();
String path = "C:\\tmp\\File1.txt";
xfer.download(path, path);  // WORKS
xfer.upload(path, path);  // ERROR

The download succeeds, but the upload gives the error:
Remote SCP command had error: scp: 'C:/tmp/File1.txt': No such file or directory

I tried:

  1. Stepping through the code and waiting a bit after the download, just to be sure it didn't still have the file open.
  2. Commenting out the download and just doing the upload.
  3. Deleting the file on the remote server just to make sure it wasn't an overwrite issue or anything.
  4. Using different file names for the local and remote - it's definitely the 2nd parameter of uploadFile (remotePath) that is throwing the error.
  5. Just specifying a path, not a filename for the remotePath

Not really sure how that could be the case. Clearly it's a valid path, because it was used for the download, which succeeded.
May be worthy of note: Both machines are Windows.
Machine at remote end is Windows 2025 running the stock MS OpenSSH server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions