BT Sync & AWS
BitTorrent Sync (BT Sync) is a tool that can be used to synchronize files between devices using peer-to-peer (P2P), technology. Using this method means that no server is storing the files between your devices. Think of it as a theoretically more secure Dropbox. I say theoretically because BT Sync is not open source, so we don't really know what it is doing beneath the covers.
I've been trying out BT Sync for a little while now and I think it is pretty good. The recent update to version 2.0 was much needed. I have it setup on my phone and my home computer. The one thing I miss is the ability to shutdown my home computer but still be able to sync files. Since BT Sync has a linux version I decided to give installing it on Amazon Web Services (AWS) a try. It turned out to be fairly easy. Below are some rough steps to get it setup. I'm not going to include anything to walk you through the setup of an EC2 instance, but I used the Ubuntu Server quick start option and set the instance type to t2.micro. All you are doing is running Bt Sync, you don't need much power. A Raspberry Pi B+ can run it without issue, trust me I did it. I will assume you used the Ubuntu quick start and have logged in to your instance via SSH. Be sure to keep the EC2 Management Console up as well, we will need to open a few ports.
- First you need to download the program to your EC2 instance. In the SSH window to your EC2 instance type/copy-paste in
and hit enter. This will download the file.
- Now we need to extract it, type in
tar -xvvzf BitTorrent-Sync_x64.tar.gzand press enter.
- In your EC2 Management Console click on the EC2 instance you created for BT Sync, then click on the link next to Security groups.
- Now you should be looking at the Security Group used for the instance. Click the Inbound tab, then click the Edit button.
- Now add a Custom TCP Rule with the Port Range as 8888 and the Source as Anywhere. Then click Save.
- Head back to your SSH console and run
./btsync. This starts BT Sync in the background
- Get your Public DNS url from your EC2 Management Console and put that into your browser at port 8888. It will be something like
http://ec2-00-00-00-00.us-west.compute.amazonaws.com:8888. You should see the BT Sync interface and it should help you get everything setup.
- Click the cog in the upper-right corner, then click Preferences, then click Advanced. Make note of the Listening Port. You will want that later. Next we need to make sure BT Sync runs on startup of the EC2 instance.
- In your SSH terminal type the following
sudo mv btsync /usr/local/bin/btsync
sudo chown root:root /usr/local/bin/btsync
sudo chmod 755 /usr/local/bin/btsync
- Go to this gist by Mendelson Gusmao. Click the Raw button next to the btsync file. Copy the URL of that raw output.
- In your SSH terminal run
wget [PASTE URL HERE]to download the file.
- Using whatever text editor you want edit the new btsync file. Replace
- Run the following commands to move the file into place and to set the permissions
sudo mv btsync /etc/init.d/btsync
sudo chown root:root /etc/init.d/btsync
sudo chmod +x /etc/init.d/btsync
- Now we need to create a config file for btsync. Run this command:
btsync --dump-sample-config > /home/ubuntu/.sync/config.json
- Open /home/ubuntu/.sync/config.json in your text editor. The first few lines will look like this:
"device_name": "My Sync Device",
"listening_port" : 0, // 0 - randomize port
/* storage_path dir contains auxilliary app files if no storage_path field: .sync dir created in the directory where binary is located. otherwise user-defined directory will be used */
// "storage_path" : "/home/user/.sync",
Change My Sync Device to whatever you want, leaving the quotes intact. Change the listening port to the value to wrote down earlier. Remove the
//before the storage_path line and change
/home/ubuntu/.sync. Save the file and the config is done.
sudo update-rc.d btsync defaultsto make sure everything runs on startup.
sudo /etc/init.d/btsync startto start the daemon. It should say Starting BTSync for ubuntu. Go to the URL you used in step 7 to make sure it is running
- Follow steps 3 - 5 again, only this time use the listening port number you used earlier.
That's all there is to it.