I have a pi-2 and a pi-3 and I am trying to transfer some files from the pi-2 to the pi-3. Is there a way besides using Bluetooth to do it?
You don't mention what OS nor which image you are running on your raspberries.
As most Linux images already have an ssh-server installed, scp is the easiest solution.
On raspbian-lite images the server is installed but disabled by default. You can start it manually with
$ sudo systemctl start ssh
Even better enabled it to start automatically on each boot with
$ sudo systemctl enable ssh
Once ssh is running it is simple to use:
If you want to push a file from the raspberry you're connected to, to another one:
$ scp localfilename username@otherRapsberryIpAddress:remotefilename
or if you want to get a file from your other raspberry to the one you're connected to:
$ scp username@otherRaspberryIpAddress:remotefilename localfilename
If your username is the same on both raspberries and you want to keep the original filename, it gets even simpler:
$ scp localfile otherRaspberryIpAddress:
$ scp otherRaspberryIpAddress:remotefile .
(don't forget the ':' after the ip address, or the '.' to specify the destination)
There are additional options available if you want to copy recursively whole directories (-R) or define a different port than the normal ssh port (-P).
If you don't have ssh-server installed, just install it, it will be useful in any case. Much easier than to set up a ftp or nfs server.
NFS is a very simple to use protocol for filesystem sharing (at least if all nodes are linux based). You can then copy files back and forth as much as you like.
My preference with NFS is use it read-only without encryption. This means the files so shared should not contain sensitive information because anyone could access them, but no one will be able to replace or modify them. If both pis are then set up the same way, they can copy files out of each other.
To illustrate (you first need to
sudo install nfs-kernel-server):
- Create a directory
/etc/exports(it will be empty) and add:
/opt/nfs -ro,sync,no_subtree_check 192.168.0.0/24
You can read what the options mean in
man exports(those are all actually defaults). The CIDR block at the end should be appropriate to whatever your LAN uses.
sudo systemctl start nfs-server sudo exportfs -a
The first command starts the
nfsdserver and such; the second applies what you've put in
/etc/exports(it's probably not necessary here, but you will need to use it if you change the contents of
exportwhile the server is running). If you are using a firewall you will have to open port 2049 to tcp, udp, and sctp.
On the other pi:
sudo mkdir /mnt/nfs sudo mount -t nfs4 192.168.0.X:/opt/nfs /mnt/nfs
The IP address there should be that of the other pi. You can instead use a hostname if, e.g., you have Avahi set up. You can then make this simpler by adding it to
whatever.hostname:/opt/nfs /mnt/nfs nfs defaults,noauto 0 0
Then you can just use
sudo mount /mnt/nfs.
Anything you put in
/opt/nfs on the first machine will then be accessible in
/mnt/nfs on the second. You can have them both set up this way at the same time (in fact, you can have multiple directories on offer and mount them all remotely). You probably then want the NFS server running at boot (
sudo systemctl enable nfs-server).