Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

James Bruce 16-09-2013

Don’t believe the hype: the Cloud is far from secure. But have no fear – now you can forget Dropbox once and for all, and show the authorities a solid middle finger by rolling your own private, unlimited, and secure cloud storage platform with a Raspberry Pi and BitTorrent Sync.


Part of this process overlaps with making a Pi-based Network Attached Storage Turn Your Raspberry Pi Into An NAS Box Do you have a couple of external hard drives lying around and a Raspberry Pi? Make a cheap, low powered networked attached storage device out of them. While the end result certainly won't be as... Read More , which you might also want to check out. If you’re really adventurous, you could even build a Raspberry Pi Twitter Bot How to Build a Raspberry Pi Twitter Bot Twitter is the world biggest repository of short messages from people with nothing to say - and now you too can contribute to that epic project with an automated Twitter bot, powered by your Raspberry... Read More that tweets out all the new files added to it. Do it.

BitTorrent? Isn’t That Illegal?!

Well, actually, no 8 Legal Uses for BitTorrent: You'd Be Surprised Like HTTP, which your browser uses to communicate with websites, BitTorrent is just a protocol. You could use your browser to download pirated content, just as you could use a BitTorrent client to download pirated... Read More – though the most common usage of the BitTorrent protocol is distributing material that falls under copyright protection. BitTorrent Sync From Pirate Darling To Dropbox Alternative: BitTorrent Sync Lets You Keep Your Files Synchronized Across Machines Cloud-based file sync services are easy to use and work well, but your privacy may or may not be your first priority. Not to mention the fact that these services always come with a storage... Read More is a separate (closed source) project from the creators of BitTorrent; it uses the same underlying file distribution principles, but with encryption and for a private group of users.

In simple terms, BitTorrent Sync is similar to Dropbox in that it syncs files and folders between authorized computers, but doesn’t require a third party cloud provider since it uses the underlying peer-to-peer distribution technologies of BitTorrent.

You Will Need

  • Raspberry Pi
  • USB storage drive
  • Computer for testing

Getting Started

Like always, I’m starting from a fresh Raspbian installation, but this should work fine with an existing installation. Grab the image from here and burn using this utility for OS X or ImageWriter for Windows. After logging in remotely through SSH Setting Up Your Raspberry Pi For Headless Use With SSH The Raspberry Pi can accept SSH commands when connected to a local network (either by Ethernet or Wi-Fi), enabling you to easily set it up. The benefits of SSH go beyond upsetting the daily screening... Read More , perform a basic system update.

sudo apt-get update
sudo apt-get upgrade

Mount Your Drive

List your drives using

sudo fdisk -l


Once you’ve identified the correct /dev device for your drive:

sudo mkdir /media/sync
sudo mount -t auto /dev/sda1 /media/sync

(assuming /dev/sda1 is your USB drive)

To ensure these are auto-mounted on restart, edit the fstab configuration file as follows:

sudo nano /etc/fstab

Add the following line, remembering:

/dev/sda1 /media/sync vfat defaults 0 0
  • /dev/sda1/ should be wherever your USB drive gets mounted
  • /media/sync is the folder you created to act as a mount point
  • vfat is the type of filesystem. Use ntfs-3g if it’s an NTFS drive, but you’ll need to also run sudo apt-get install ntfs-3g. For Linux partitions, ext4 is common.

Install BitTorrent Sync

Luckily, there’s now an easy way to install without messy compiling – but we do need to add a custom source to find the package files. Use the following commands, pasting one by one.

sudo gpg –keyserver –recv-keys 6BF18B15
sudo gpg –armor –export 6BF18B15 | sudo apt-key add -
sudo echo deb wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo echo deb-src wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo apt-get update
sudo apt-get install btsync

Note that if you get permission errors on the sources.list.d file, try editing the file manually with Nano:

sudo nano /etc/apt/sources.list.d/btsync.list

and paste in these lines.

deb wheezy main contrib non-free
deb-src wheezy main contrib non-free

The go ahead with the update and install commands as before.

Upon installing the package, you’ll be greeted with a special installation script. Create a “default instance” operating on any random port number – I chose 55555.


I ran through the installation and accepted the defaults for everything else (except for password, obviously).


Check If BitTorrent Sync Is Working

The installation script should have added it to the startup file, so go ahead and restart to check this:

sudo shutdown -r now

Give it a minute or so to restart, then user another PC to browse its web interface – that is, type the IP address of your Pi, followed by a colon, and the web interface port chosen during setup – the default being 8888; so I typed http://192.1680.9:8888 . After logging in, you should be greeted with this.


Create a folder pointing to your /media/sync directory or wherever you chose to mount the drive earlier. The secret passphrase is the key to all your files – never give it out to anyone you don’t trust.


The app begins by indexing the drive is there’s already files there, which may take a while.


In the meantime, you can safely go ahead and install the BitTorrent Sync application onto your other machines, choosing to paste in your secret passphrase during the setup process. Choose the relevant directory to be used to sync locally, and your files should immediately be pulled across from the Pi and begin syncing (if you had any there to begin with – I used a data drive already containing a few hundred gigabytes of files).


The History tabs shows a record of what files have been added by which device. Transfers shows which files are currently being synced, either up or down.

For advanced setups, click the cog icon next to the folder in the web GUI, where you’ll be able to grab a secret passphrase for read-only access, or generate a one-time passphrase to avoid giving out the master key.


In practice, the Pi uploads at about 600-700 kB/s, but I set a hard limit of 1 MB/s just in case. The initial sync is going to take a long time if you have terabytes of data – but remember, the more computers you have in your private BT Sync network, the faster subsequent syncs will be (the same as “seeding” principles for regular torrents).

Is It Really Secure?

Latest revelations show that the NSA may in fact have broken a large number of encryption schemes commonly used to secure services such as VPNs, so how about BitTorrent Sync? Experts believe the AES-256 encryption used there has yet to be cracked. Snowden himself said:

“Encryption works. Properly implemented strong crypto systems are one of the few things that you can rely on”

Can you think of a use for your own private Dropbox? Perhaps a family photo album that automatically syncs to everyone – BitTorrent Sync is ideal for large files as can be the case with modern cameras. Sending large photos over email is infuriatingly slow, but I find compressed photos even more annoying! What will you use yours for?

Image credit: adafruit/flickr, Kamil Porembi?ski/flickr

Related topics: BitTorrent, Cloud Storage, Peer to Peer, Raspberry Pi.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. sprale
    August 5, 2016 at 9:19 pm

    If only I could set this up on a Pi that was already running Kodi...

  2. Bruno
    April 1, 2015 at 3:23 pm


    I 'm having difficulties telling it to sync /backups, I'm setting up appliances using Minibian OS and Raspi 2.

    It must be related to permission issues but I'm at a lost.

    If I keep all to default when installing bit sync on Minibian. Which permissions should I assign to /backups/ so backupninja can read and write to it while at the same time bit sync can at least read?

    All I've tried so far only enables me to see /mnt even if I specify / or /backups as the sync directory. Ad even then, it seems only to sync the /mnt folder itself but not its contents.

    Any suggestions?


  3. Stanny
    February 25, 2014 at 6:01 pm

    Amazing stuff!
    This is my setup: Raspberry Pi (B) + Raspbian + Deluge (daemon/console/web) + Flexget + BTsync + Filegator makes for the perfect leechbox ^^

  4. falu
    December 25, 2013 at 11:08 am

    sudo gpg --keyserver --recv-keys 6BF18B15
    sudo gpg -armor --export 6BF18B15 | sudo apt-key add -

  5. Kensinxxx
    December 25, 2013 at 6:03 am

    Hai Frost :)
    can i ask u?
    sudo gpg –armor –export 6BF18B15 | sudo apt-key add -
    whats wrong with this command??
    this will appear :: gpg: no valid OpenPGP data found.

  6. NoBodyCares
    December 23, 2013 at 10:45 pm

    Why doesn't this work with my ddns?

  7. Ibrahim
    December 21, 2013 at 8:13 pm

    I'm getting :E: Unable to locate package btsync
    when I try E: sudo apt-get install btsync

    Any help??

    • James B
      December 21, 2013 at 8:16 pm

      Yep - follow the instructions posted above by Frost for correctly adding the repository, the editor managed to strip the correct from this post for some reason.

  8. António
    December 21, 2013 at 2:24 am

    Will I be able to access this from outside my network?

    • James B
      December 21, 2013 at 9:27 am

      Yes. You don't "access it" as such though - you run BTSync on any machine you want to stay in sync with the Pi server. The more machines you have, the faster files will sync (just like a torrent file with many seeds)

  9. Frost
    December 6, 2013 at 9:05 pm

    Please correct the syntax of console commands:

    sudo gpg --keyserver --recv-keys 6BF18B15
    sudo gpg --armor --export6BF18B15 | sudo apt-key add -
    sudo echo deb wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
    sudo echo deb-src wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
    sudo apt-get update
    sudo apt-get install btsync

    • MakeUseOf TechGuy
      December 7, 2013 at 8:41 am

      Thanks Frost, looks like WordPress nuked some of the original code thinking it was html tags

    • Frost
      December 7, 2013 at 2:20 pm

      And sorry again, but in my code there is also a one bug: –export 6BF18B15

      Second line should have a space between export and key name. Shame on me ;) And I was rude to you, because I didn't say thank you, for this article. So now, thank you. I would kiss you if I was a girl.

      • MakeUseOf TechGuy
        December 9, 2013 at 9:02 am

        Heh, thanks again for the fix and the compliment, and the potential kiss!

    • Pang
      December 23, 2013 at 2:45 pm

      Hi Frost, I keep getting errors at this stage.
      sudo gpg –keyserver –recv-keys 6BF18B15
      Returns : usage: gpg [options] [filename]

      sudo gpg –armor –export 6BF18B15 | sudo apt-key add -
      Returns : usage: gpg [options] [filename]
      gpg: no valid OpenPGP data found.

      sudo echo deb wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
      Returns : -bash: /etc/apt/sources.list.d/btsync.list: Permission denied

      Anyone knows what's happening here?

    • Frost
      December 23, 2013 at 7:01 pm

      Hello Pang, try to use double "-" before keyserver and recv-keys. But write them by yourself instead of copying my comment and adding them to this parameters. In my comment there is lack of them because WordPress changed them to one "-" in long version (like Microsoft Word is doing sometimes) and I didn't noticed it. Let me know please if it will help, if no I'll try again to figure it out with you.

    • Pang
      December 25, 2013 at 9:17 am

      Hi Frost, now it is trying to connect to some server in but here is the result...

      gpg: requesting key 6BF18B15 from hkp server
      ?: Host not found
      gpgkeys: HTTP fetch error 7: couldn't connect: Success
      gpg: no valid OpenPGP data found.
      gpg: Total number processed: 0

  10. Ryan
    October 10, 2013 at 1:35 pm

    Great article guys, I think this is what i'm after to complete my RPI build.

    I want to share files I automatically download to the Pi with my Dad, he lives miles away. Would he be able to log onto a web portal and pick which files he want's to download? Or do you guys know of a way this can be achieved?

  11. petez
    September 27, 2013 at 3:27 am

    To clarify, I don't understand if I'd have to mount every single folder individually, or if the sudo lines establish a shared path for BT Sync. Thanks again.

    • James B
      September 27, 2013 at 10:15 am

      Create the separate folders in media/sync, and just point BTSync at each one to create different secrets. Make sense? You wouldn't need to adjust the mount points.

    • petez
      September 27, 2013 at 6:29 pm

      Yes, thanks.

  12. petez
    September 27, 2013 at 3:24 am

    I'm already using BT Sync to share files between several computers, using several different secrets. One, for example, only handles things I want to share with my Android tablet, which has limited storage. Would I need a separate instance of your "/media/sync" example for each of my existing folder/secrets? If so, I stink at Linux: could you please show what a multiple secret setup looks like? Thanks!

  13. Guy M
    September 17, 2013 at 1:42 pm

    Dammit James! Quit writing cool articles like this - my ToDo list is already a mile long. :D

    • dragonmouth
      September 17, 2013 at 11:58 pm

      "my ToDo list is already a mile long."
      Are you using Evernote to store the list on your smart phone? :-)

    • Guy M
      September 19, 2013 at 12:56 pm

      Is it sad or funny that I actually am using Evernote to store the list on my smart phone?

  14. m3adow
    September 17, 2013 at 11:44 am

    Is it really secure? No! No it isn't.

    Since Bittorrent Sync isn't Open-Source, you can't be certain how the encryption is implemented or if there's a backdoor.

    If you want privacy by encryption, use OpenSource Encryption like GnuPG or Truecrypt and avoid blackbox encryption like BTsync or Bitlocker.

  15. Joseph Z
    September 16, 2013 at 6:51 pm

    Done! Works good. I installed transmission on my RPI and have it getting the .torrent files from BTSync and using BTSync to send the downloads back to my PC. All without needing to forward ports at the remote location. STEALTH!!