2

I want to do something like

scp JoeBloe@WindowsHost:c:\Some Folder\foo.txt c:\temp

I know this is a matter of getting the quoting right both in the local shell and ensuring the remote host also received the right quoting (so double quoting will probably be required). I have tried various combinations of quoting but I just get "File does not exist" or it just pauses for while but does nothing. I have not problem with paths without spaces so its not a permission problem.

Note this is not the same as question the question that was identified as a possible duplicate. That question was for the case when there is a space in the target path and where the source OS is UNIX. In this case it is the source path and where both the client and source OS are widows. Also, I am using OpenSSH not pscp.

2 Answers2

1

If you use scp command integrated in Windows 10 since 2018, then you can run:

scp JoeBloe@WindowsHost:"\"\"C:\Some Folder\foo.txt\"\"" c:\temp

If scp still cannot find the file, then add -v (verbose) flag to the command:

scp -v JoeBloe@WindowsHost:"\"\"C:\Some Folder\foo.txt\"\"" c:\temp

to see what file scp is looking for on the remote host. The output should contain these lines:

Executing: program ssh.exe host 10.8.0.1, user JoeBloe, command scp -v -f ""C:/Some Folder/foo.txt""
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Connecting to 10.8.0.1 [10.8.0.1] port 22.
debug1: Connection established.
...
debug1: Sending command: scp -v -f "C:/Some Folder/foo.txt"
...

The method is similar to the method in this answer, except that I had to use triple quotes - but I do not know why. I could not escape spaces using single, double or triple backslashes: \, \\, or \\\ - in each case, the backslashes were changed to slashes.

iwis
  • 301
0

You can use:

scp user@IP.ADDRESS:"C:\Path\To\File.txt\" C:\Path\To\Save\File.txt

to save it. The previous answer did not work for me since there was an extra pair of \" in there.