How do I copy a folder from remote to local using scp?

Slasengger picture Slasengger · Jul 3, 2012 · Viewed 2.5M times · Source

How do I copy a folder from remote to local host using scp?

I use ssh to log in my server.
Then, I would like to copy the remote folder foo to local /home/user/Desktop.

How do I achieve this?

Answer

Gryphius picture Gryphius · Jul 3, 2012
scp -r [email protected]:/path/to/foo /home/user/Desktop/

By not including the trailing '/' at the end of foo, you will copy the directory itself (including contents), rather than only the contents of the directory.

From man scp (See online manual)

-r Recursively copy entire directories