scp recursive command for local to remote copy

AJW picture AJW · Aug 22, 2014 · Viewed 8.1k times · Source

So, I have been doing some scp stuff recently from my local machine to my server, and today, by mistake, I excecuted the following:

scp -r myfolder [email protected]:/home/myhome .

What I meant to do was to copy myfolder from my local machine to my remote, but I had forgot to set the folder and used . at the end by mistake.

Now, the first output I got was:

cp: `myfolder' and `./myfolder' are the same file

and then, it went on to transfer a range a files ( a lot of them).

Now, I am totally clueless what happened - and where the transferred files are.

Not that this is of any concern i.e in terms of security etc, but I am trying to learn here what really happened when I used:

scp -r myfolder [email protected]:/home/myhome .

Answer

Aaron Digulla picture Aaron Digulla · Aug 22, 2014

. is the current folder. The command above copied the folders myfolder and [email protected]:/home/myhome into the current folder, hence the error message that you tried to copy myfolder to myfolder.

I'm a bit surprised that scp didn't stop after the error. Since it didn't, you'll find a new folder myhome next to myfolder with files from your server.