File sync is awesome. Without the ability to get at my files on all my computers (4, currently), I don’t know how I would function. That said, I’m not super-fired-up about Dropbox’s security and privacy practices (or Google Drive’s, for that matter), particularly in light of recent news.
So I got pretty excited when I learned about BitTorrent Sync, software that syncs your files without requiring you to give the key to those files to a company like Dropbox or Google. Like its namesake, BitTorrent Sync is decentralized. It syncs files between the computers you install it on, and does not rely on any central server.
Unfortunately, the lack of a central server is also a downside. If you have a desktop and laptop, for example, BitTorrent Sync will only sync up your files when both of your computers are turned on and connected to the Internet. That’s not a problem with Dropbox, because Dropbox’s servers keep your files synced up all the time, even if your computers are never connected to the Internet at the same time. But if you got BitTorrent Sync running on your own server, you could get this same functionality.
That’s why I figured out how to install BitTorrent Sync on an Amazon EC2 server. Here’s how I did it (with crucial help from the friendly folks on #ubuntu-server at freenode).
Step 1: Install BitTorrent Sync on your computer
Go to the BitTorrent Sync page and download BitTorrent Sync for your computer. Install it in the usual way for your operating system, and run it. Go ahead and accept all the defaults.
You will wind up with a /BTSync folder in your home directory. You can also create other folders to sync and share, but this one will get you started.
Step 2: Provision a new Ubuntu server instance
This sounds harder than it is. Amazon has added a “quick launch” option for dummies like me that makes creating a new server trivial.
- Create an account at aws.amazon.com. This should take 5–10 minutes, counting the time it takes to verify your account over the phone.
- Once your account is set up (you will get an email notifying you that you are good to go), go to your EC2 Dashboard and click the Launch Instance button. Then, select Quick Launch Wizard on the left in the pop-up window. This allows you to provision a new server without having to mess around with all the settings.
- Now, enter a name for your server. “BitTorrent Sync Server” will do just fine.
- Under Choose a Key Pair (which you will need to download and use in the next step), Create New should be pre-selected. Enter a name. “btsync-keypair”, for example. Click the Download button to download your key pair, and make sure you will be able to find it again.
- Under Choose a Launch Configuration, select the Ubuntu Server option that has LTS in the name, and leave the 64-bit radio button selected. LTS stands for “long term support,” which means you will get security updates from Canonical for 5 years, which means you don’t have to worry about upgrading your server’s operating system any time soon.
- Click the Continue button, and voila!
Step 3: Install BitTorrent Sync on your new server
Go to the BitTorrent Sync page and copy the link to the correct download. (Use the Linux x64 link if you installed a 64-bit Ubuntu server like I told you to.)
On your server, create a folder for the BitTorrent Sync software:
And another for your files:
This folder is not encrypted, which means anyone with access to your server (read: Amazon) can read your files. If you want to encrypt your files, you can use an encrypted private folder or create an encrypted volume with TrueCrypt.
Change to the
Now, download BitTorrent Sync (using the download link you copied above):
And unzip it (adjust the file name in this command if you downloaded a different version):
tar -zxvf btsync_x64.tar.gz
Finally, run it:
Step 4: Connect to your new BTSync server
In order to access BTSync’s web interface on your server, you will need to create an SSH tunnel on your computer using local port forwarding. Trust me, you don’t need to know what that means to do it. In brief, though, what it means is you are creating a secure pipeline for your computer to access your BitTorrent Sync web interface.
We’re going to use the terminal. That’s the command line. Don’t be afraid. I will walk you through it.
This is cake on a Mac or Linux PC. On a Mac, just hit Cmd+Space (or click the magnifying glass in the upper right), type “terminal”, and hit return. (In Linux, I’m just assuming you know where to find the terminal by now.) Windows users will need to install PuTTY in order to follow the rest of the steps in this tutorial.
Once you have your terminal up, navigate to the directory where you saved your key pair. For me, that means:
Now, enter the following string:
sudo ssh -i keypair.pem -L 8888:127.0.0.1:8888 ubuntu@ec2-##-###-##-##.us-west-2.compute.amazonaws.com
keypair.pem with the name of your key pair file, and replace everything after
ubuntu@ with the location of your Amazon EC2 instance. To get the location of your EC2 instance, go to the EC2 dashboard (it’s probably still open in a browser tab), click on Instances in the sidebar, check the box next to your instance, and look down. You should see a string of letters and numbers that begins with
ec2 and ends with
compute.amazonaws.com. That’s what you need.
Now, use your browser to navigate to:
If it works as it should, you should see a web page with this logo:
Once you close your terminal session, you will no longer be able to access your server’s BitTorrent Sync web interface. Don’t worry, it is still syncing your files. However, any time you want to access your web interface, you will need to follow the above steps. I’m sure there is a better way to set this up, and I hope somebody will figure it out and post a tutorial.
Now, click the Add Folder button, then paste
/home/ubuntu/BTSync into the Path field.
For the Secret field, go back to the BitTorrent Sync app you installed on your own computer and click on Folders. Right-click on the /BTSync folder on your computer, and select Copy secret. Now, go back to your browser, and paste the secret into the Secret field.
Click the Add button.
Step 5: Sync!
Now, anything you add to the /BTSync folder on your computer will be synced with your server. Try it. Keep your server’s BitTorrent Sync web UI open in your browser and add a file to your local /BTSync folder. Very shortly, you should see the Size column update with the new size and number of files.
If you install BitTorrent Sync on another computer using the same secret key, the files will sync up to that computer, too. You are basically rolling your own Dropbox! Take a few moments to read up on the other neat stuff you can do with BitTorrent Sync, including sharing folders, one-way synchronization, and more.
Caveat: While your new BitTorrent Sync server will start out on the AWS Free Usage Tier, you will have to pay for it after 1 year (or if you exceed the micro tier limits). If I’m reading the pricing details right, that would be around $175/year, if you stay within the micro tier (n.b., I’m not at all confident I understand the pricing). Anyway, keep an eye on your account details.
- 2013-06-08 Added additional pricing information and notice regarding encryption.