Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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, which you might also want to check out. If you’re really adventurous, you could even build a Raspberry Pi Twitter Bot that tweets out all the new files added to it. Do it.

BitTorrent? Isn’t That Illegal?!

Well, actually, no – though the most common usage of the BitTorrent protocol is distributing material that falls under copyright protection. BitTorrent Sync 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 Raspian 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, perform a basic system update.

sudo apt-get update
sudo apt-get upgrade

Mount Your Drive

List your drives using

sudo fdisk -l

fdisk l   Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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 pgp.mit.edu –recv-keys 6BF18B15
sudo gpg –armor –export 6BF18B15 | sudo apt-key add -
sudo echo deb http://debian.yeasoft.net/btsync wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo echo deb-src http://debian.yeasoft.net/btsync 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 http://debian.yeasoft.net/btsync wheezy main contrib non-free
deb-src http://debian.yeasoft.net/btsync 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.

pi btsync config   Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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.

btsync initial screen   Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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.

sync secret passphrase   Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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

sync indexing   Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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).

osx sync file activity   Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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.

sync connected devices   Build Your Own Cloud Storage with Raspberry Pi and BitTorrent Sync

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

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

27 Comments -

Joseph Z

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!!

m3adow

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.

Guy M

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

dragonmouth

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

Guy M

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

petez

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!

petez

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

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

Yes, thanks.

Ryan

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?

Patric

@JamesB I’ve tried OwnCloud on Raspberry Pi and unfortunately raspberry pi is a bit too slow. I ran nginx with php and owncloud ran too slow to be used.

Frost

Please correct the syntax of console commands:

sudo gpg –keyserver pgp.mit.edu –recv-keys 6BF18B15
sudo gpg –armor –export6BF18B15 | sudo apt-key add –
sudo echo deb http://debian.yeasoft.net/btsync wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo echo deb-src http://debian.yeasoft.net/btsync wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo apt-get update
sudo apt-get install btsync

MakeUseOf TechGuy

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

Frost

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

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

Pang

Hi Frost, I keep getting errors at this stage.
sudo gpg –keyserver pgp.mit.edu –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 http://debian.yeasoft.net/btsync 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

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

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

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

AntĂłnio

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

James B

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)

Ibrahim

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

Any help??

James B

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.

NoBodyCares

Why doesn’t this work with my ddns?

Kensinxxx

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.

falu

sudo gpg –keyserver pgp.mit.edu –recv-keys 6BF18B15
sudo gpg -armor –export 6BF18B15 | sudo apt-key add -

Stanny

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