1

I have been trying to copy a directory using SCP from windows to my Ubuntu server. it looks like it has completed the transfer on the windows CMD but when I use

ls 

on the server in the location I copied it to, the directory I copied doesn't show up.

This is the command I am using on windows

scp -r C:\local\directory\ remoteUser@ip/remote/directory

this will show it's copying and say it as copied x files but when I try access these on the remote server I cannot

The craziest thing is that when I revers the scp command like this:

scp -r remoteUser@ip/remote/directory C:\local\directory\

it will copy all the files back to the windows device from the remote server as if they were there all along

Does anyone have any idea what is happening here?

7
  • 6
    Totally untested, so just a comment. remoteUser@ip/remote/directory does not contain a colon and therefore it's a local path; remoteUser@ip:/remote/directory would be a remote path. In Linux scp uses cp when copying from local to local, I don't know scp on Windows. Anyway, check the local path you thought was remote. Commented Nov 9, 2022 at 4:59
  • I do that all of the time! scp file user@host creates a local file while scp file user@host: is what I want.
    – Stewart
    Commented Nov 9, 2022 at 7:32
  • @Stewart My solution to this problem. Commented Nov 9, 2022 at 7:38
  • @KamilMaciorowski no use on a source Windows platform, as described here Commented Nov 9, 2022 at 9:14
  • @roaima It's my solution and I don't use Windows. :) Commented Nov 9, 2022 at 9:16

1 Answer 1

3

Try this syntax:

scp C:\local\directory\* remoteUser@ip:/remote/directory/

What you're missing is the : ([user@]host:[path]) that separates the remote server path from the SSH line.

The source and target may be specified as a local pathname, a remote host with optional path in the form [user@]host:[path], or a URI in the form scp://[user@]host[:port][/path]. Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers.

2
  • 2
    Worth mentioning that the OP has created a directory ("folder") on their local Windows system called remoteUser@ip. And also that scp would have listed the copy source/destination, showing quite clearly that it's a local copy (mkdir xx, echo boo > xx\boo.txt, scp -r xx ru@ip/r/d results in output that includes C:\Users\Roaima\Documents\xx\boo.txt -> C:\Users\Roaima\Documents\ru@ip\r\d\boo.txt Commented Nov 9, 2022 at 9:08
  • Thank you, problem solved
    – Mater
    Commented Nov 9, 2022 at 9:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .