Bash command to copy a file from one computer to another

Not sure how to say this, but let me say that I used ssh to remotely access my MacBook friends (macbook_b) from my MacBook (macbook_a).

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

Thanks.

+6
source share
4 answers

You can use scp (Secure Copy).

To copy your car to friends:

 scp file_to_copy user@remote.server.fi :/path/to/location 

In the other direction:

 scp user@remote.server.fi :/path/locatio/file_name file_name 

If you need to copy the entire directory, you will need to use a recursive flag, for example:

 scp -r directory_to_copy user@remote.server.fi :/path/to/location 
+16
source

Assuming you are logged in to macbook_b:

 scp file_to_copy username@macbook _a:/path/to/destination 

or if you are logged in to macbook_a:

 scp username@macbook _b:/path/to/file_to_copy local_destination 
+3
source

do pwd first to get your macbook friend file path then

go to your ssh computer window and do

scp username @ computer_name (your friend) :( copy path after pwd is executed) / file_name (dot means your current directory)

enter password!

voila !!!

0
source

Source: https://habr.com/ru/post/919036/


All Articles