bash command to copy file from one computer to another

MorganR picture MorganR · Jun 26, 2012 · Viewed 37.6k times · Source

Wasn't quite sure how to word this but let's say I've used ssh to remote into my friends MacBook (macbook_b) from my MacBook (macbook_a).

What command would I use to copy a file/directory to my MacBook (macbook_a) from my friends MacBook (macbook_b)?

Thank you.

Answer

maxwell picture maxwell · Jun 26, 2012

You can use scp (Secure Copy).

To copy FROM your machine to friends:

scp file_to_copy [email protected]:/path/to/location

In another direction:

scp [email protected]:/path/locatio/file_name file_name

If you need to copy an entire directory, you'll need to use the recursive flag, like this:

scp -r directory_to_copy [email protected]:/path/to/location