Search code examples
macosbashunixcp

bash command to copy file from one computer to another


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.


Solution

  • 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