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?
In the 6 years since I posted this Answer many things have changed.
macOS Samba support has improved and Apple now uses Samba as its default for file sharing (and afp doesn't work with newer Apple filesytems)
Debian Buster now uses netatalk 3 - which has significant changes, and requires more configuration to do anything useful.
nfs support in much better in recent Raspbian, but still has problems with write permission from macOS.I use all of ftp, Samba, afp and nfs;
principallyftp
(Filezilla) for routine file transfer to/from the Pi
andSamba
for browsing the Pi Home and shared filesystems and to loop mount my backup images for backup/restoration.
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 unnecessary 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.
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.
scp
does not usually require sudo
, should work fine without it.
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.
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 [email protected]:/path/to/copy/of/world2/
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
.
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/ [email protected]:world2
(assuming that world2
is a directory, this command would copy the contents of world2
to the /world2
directory on the remote machine)
The easiest way I found was using Cyberduck.
deselect anonymous login & then connect.
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
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.
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.
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.
scp
and/orsftp
. If your ssh already works, they should be available. There is also ansshfs
, which allows mounting of shares a la NFS.