19

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.

MorganR
  • 619
  • 3
  • 11
  • 22

4 Answers4

34

You can use scp (Secure Copy).

To copy FROM your machine to friends:

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

In another direction:

scp user@remote.server.fi:/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 user@remote.server.fi:/path/to/location
maxwell
  • 857
  • 8
  • 16
3

Assuming you're logged in on macbook_b:

scp file_to_copy username@macbook_a:/path/to/destination

or if you're logged in on macbook_a:

scp username@macbook_b:/path/to/file_to_copy local_destination
Terje Mikal
  • 938
  • 6
  • 16
  • I keep getting "cp: username@computerName is not a directory" error. Do you know what causes this? I am using 'scp' as well, not 'cp'. – MorganR Jun 26 '12 at 14:10
  • @MorganR: it looks like that for some reason the "cp"-command gets executed instead of "scp". Maybe you have an alias for "scp" that points to "cp", or maybe the "scp"-command is replaced by "cp"? – Terje Mikal Jun 26 '12 at 14:16
  • I missed out the ":" when referencing where I want the file to be copied. Always something simple. Thank you for your help, Terke Mikal. – MorganR Jun 27 '12 at 09:15
0

I think this link would help you with the answer you are looking for. In this you can use scp ssh source destination example for your scenario you have requested for.

Also refer to this question which has been already answered. It might help.

Community
  • 1
  • 1
Siva Karthikeyan
  • 544
  • 8
  • 25
0

first do pwd to get the path to the file of your friends macbook then

go into your machine's ssh window and do

scp user_name@machine_name(of your friend's):(copy the path after executing pwd)/file_name .(dot means your your current directory)

enter his password !

voila !!!

Sanjay Rao
  • 547
  • 1
  • 11
  • 22