11

I have a Pi running headless using ssh and Screen Sharing on OSX and tightvncserver on raspbian.

Can I copy files from the Mac to/from the Pi using ssh or Screen Sharing (i.e. VNC) or do I need to use Samba or similar?

  • 4
    See scp and/or sftp. If your ssh already works, they should be available. There is also an sshfs, which allows mounting of shares a la NFS. – goldilocks Aug 11 '13 at 13:03
  • 1
    scp over ssh work fine for me. I myself use Cyberduck for file transfer, as I can just drag and drop, like in finder. – Gerben Aug 11 '13 at 15:15
  • 1
    I used sftp (using FileZilla) which got the files there, so query now closed. (I would have marked this as accepted.) – Milliways Aug 12 '13 at 0:36
  • Note that ssh encryption can be slow on the Pi. I found blowfish to be fastet CPU wise some years back. – Thorbjørn Ravn Andersen Aug 23 '13 at 6:14
  • NFS is another option and makes the most sense in Unix world as is native. – jet Sep 7 '15 at 20:01
17

I used ftp to solve my problem (as noted above), but recently discovered another method, which other Mac users may find useful.

sudo apt-get install netatalk

Installs the appletalk protocol on the Pi. This lets you use the following (at the terminal prompt on the Mac) to connect to the Pi

open afp://10.1.1.10  (replace this with your Raspberry Pi IP address)

You can then use Finder (or any other FileManager e.g. QuollEyeTree) to transfer files to or from the Pi, using the same techniques you would use on the Mac

Note: This edit is by another user, and AFAIK is unecessary If you get the error Couldn't get a file descriptor referring to the console with open afp command try again with sudo, also, make sure you have remote login configured on your mac.

  • @Paul Fort: as you origianlly added it, what is "open afp command"? Should "afp" be "ftp"? – Peter Mortensen Jul 27 '14 at 12:10
  • @PeterMortensen have you tried it (or checked the Mac help)? – Milliways Jul 27 '14 at 13:41
  • 1
    This is awesome. Love it! Thanks for the tip, was not aware of the ability to do this. – gdgr Dec 9 '15 at 23:39
7

if you can use ssh, then most probably scp (SSH copy) will work as well.

i would install samba anyway, because there are too many winboxen everywhere and the next thing you might need will be the access from windows.

  • I tried scp on the Mac but while this appeared to work no files appeared (I used "sudo scp -v world2 //pi@10.1.1.10:" and variants). I have used scp (on Pi) to transfer rsa keys. sftp seems the easiest option. – Milliways Aug 12 '13 at 0:44
  • scp does not usually require sudo, should work fine without it. – lenik Aug 12 '13 at 2:07
  • scp from a Mac to RPi works as expected and doesn't require any additional software on the RPi. netatalk works well too, but of course, adds software and overhead that might only be used occasionally. – bobstro Oct 1 '15 at 12:05
3

Did you try scp with the -r flag? Because without it, it won't perform a recursive copy.

If you were looking to copy the file or folder world2, this is how I would do it:

$ scp -rv world2 pi@10.1.1.10:/path/to/copy/of/world2/
  • Excellent command. Quick and easy. Thank you very much. – GutierrezDev Jun 25 '16 at 23:28
  • You can make scp much easier to use if you define your hosts in ~/.ssh/config (see nerderati.com/2011/03/17/…) — if you configure your host as rpi, then you can use something like scp -r world2 rpi:/path/to/copy/of/world2/. Just in case it is not obvious, it works the other way too, e.g.: scp rpi:.bashrc somedir. If a path is not absolute then it will be relative to $HOME. – ccpizza Nov 11 '17 at 14:16
2

If you have a lot of files, you might also consider using rsync. You'd be able to use the -P flag (for --partial --progress), which is handy when you're anticipating a long transfer with potential interruptions - that way the partially-transferred files will be retained (under normal circumstances they're deleted), so that when you resume the transfer, it won't take as long to finish the transfer.

So in your case you could do:

rsync -avP world2/ pi@10.1.1.10:world2

(assuming that world2 is a directory, this command would copy the contents of world2 to the /world2 directory on the remote machine)

1

If it's a longer term solution, another option is installing Syncthing or Bittorrent Sync on both machines. It keeps directories on multiple machines syncronized and can handle large files and directories. It's very handy as a file server, backup, and for transferring files.

I just switched to Syncthing from btsync. Syncthing provides more options and control (and btsync has proprietary code).

Their Debian/Ubuntu package at apt.syncthing.net worked fine for me and I used this tutorial as a guide

0

The easiest way I found was using Cyberduck.

  1. Open new connection
  2. Select SFTP from dropdown menu
  3. Server: put the Pi's IP address
  4. Username: should be 'pi'
  5. Password: should be 'raspberry' by default unless you changed it

deselect anonymous login & then connect.

0

Installing MacFusion on your Mac will allow you to mount your Pi over SSH, similar to how you would mount a usb stick on your Mac. Then you can use the finder to copy files to any folder on the Pi as you please.

0

Set up SMB sharing on your Pi, http://raspberrywebserver.com/serveradmin/share-your-raspberry-pis-files-and-folders-across-a-network.html

Then, on your Mac, go to finder > go > connect to server (cmd+k) > and enter the address of your pi smb://192.Ras.Pi then you can navigate the folder structure, copy/paste files, etc.

  • Why bother posting an answer to a 2 year old question with an accepted answer. This isn't even a good answer, as SMB is a b. of a protocol. If you have a Mac try the answer. – Milliways Sep 30 '15 at 23:38
  • Why bother posting an unhelpful comment to a perfectly good answer which is different to every other solution provided? There are multiple ways to move files from one place to another, this one doesn't require installing any other software on the mac, and doesn't require extensive use of the terminal. Why post it on a N years old thread? A) the solution is still good, B) the question is still relevant - I did a google search this morning and this is the first result C) this solution is different than the other solutions provided. – jrubins Oct 1 '15 at 4:20
  • I had alluded to this in the original question "or do I need to use Samba or similar" and (implicitly) excluded it. – Milliways Oct 1 '15 at 5:12
  • "Or do I need to use Samba or similar" isn't exclusionary language. So, I apologize for giving you a perfectly good answer that (in most cases, since Samba is already installed on many RPi distros) is much easier than any of the other answers provided. I really don't see why you feel the need to argue with my answer and downvote it. Just because you have 5000 reputation on Stack Exchange doesn't mean you aren't being a dickhole. – jrubins Oct 1 '15 at 16:19
-1

Just use FileZilla and set a new site from site manager on File Menu. Then select SFTP and fill in with you Rasp username and password and you're good to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.