scp copies folder but not contents of the folder

I have been trying to get this to work for a few days now, but I can’t figure it out. I am trying to scp a folder full of .tar files from my Ubuntu-Server Server to my Windows Desktop. I want to push it from my server to my Desktop, because I’d like to automate the process via a bash script.

I am using a command like this:

scp -r path/to/folder Username@Windowsmachineip:C:/path/to/folder/

When I execute the command, I get the error no such file or directory, but it does create a folder with the name of the folder on my server.

What I can do is a copy single files, but only if I specify a name for the file on my desktop, like this

scp -r path/to/folder/file Username@Windowsmachineip:C:/path/to/folder/file

If I try it without the filename at the end, I get the same error. I also tried it with the -p flag, following a suggestion, but that throws the same error. I tried pulling from the Server to my desktop, but get the same error. I also tried sftp which gives this output:

dest open "/E:/backup/minecraft/backup_minecraft_24_03_2024_06:01:04.tar": No such file or directory
upload "backup/minecraft/backup_minecraft_24_03_2024_06:01:04.tar" to "/E:/backup/minecraft/backup_minecraft_24_03_2024_06:01:04.tar" failed

The error I get with scp and -v flag is:

scp: debug1: fd 3 clearing O_NONBLOCK
Sending file modes: C0666 471111680 backup_minecraft_23_03_2024_22:29:33.tar
Sink: C0666 471111680 backup_minecraft_23_03_2024_22:29:33.tar
scp: E:/backup/minecraft/backup_minecraft_23_03_2024_22:29:33.tar: No such file or directory

Why doesn’t this work?

Asked By: Tim_Schmock


You have colons in your filenames: backup_minecraft_23_03_2024_22:29:33.tar

These are not permitted characters for Windows systems. Remove (or replace) the colons and the files will transfer correctly

The following [are] reserved characters:

  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)
Answered By: Chris Davies
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.