How to share files between computers over network with btsync

If you are the type of person who uses several devices to work online, I'm sure you must be using, or at least wishing to use, a method for syncing files and directories among those devices.

BitTorrent Sync, also known as btsync for short, is a cross-platform sync tool (freeware) which is powered by BitTorrent, the famous protocol for peer-to-peer (P2P) file sharing. Unlike classic BitTorrent clients, however, btsync encrypts traffic and grants access to shared files based on auto-generated keys across different operating system and device types.

More specifically, when you add files or folder to btsync as shareable, corresponding read/write keys (so-called secret codes) are created. These keys are then shared among different devices via HTTPS links, emails, QR codes, etc. Once two devices are paired via a key, the linked content can be synced directly between them. There is no file size limit, and transfer speeds are never throttled unless you explicitly say so. You will be able to create accounts inside btsync, under which you can create and manage keys and files to share via web interface.

BitTorrent Sync is available on multiple operating systems including Linux, MacOS X, Windows, as well as Android and iOS. In this tutorial, I will show you how to use BitTorrent Sync to sync files between a Linux box (a home server), and a Windows machine (a work laptop).

Installing Btsync on Linux

BitTorrent Sync is available for download from the project's website. I assume that the Windows version of BiTorrent Sync is installed on a Windows laptop, which can be done very easily. I will focus on installing and configuring it on the Linux server.

In the download page, choose your architecture, right click on the corresponding link, choose Copy link location (or similar, depending on your browser), and paste the link to wget in your terminal, as follows:

For 64-bit Linux:

# wget http://download.getsyncapp.com/endpoint/btsync/os/linux-x64/track/stable

For 32-bit Linux:

# wget http://download.getsyncapp.com/endpoint/btsync/os/linux-i386/track/stable

Once the download has completed, extract the contents of the tarball into a directory specially created for that purpose:

# cd /usr/local/bin
# mkdir btsync
# tar xzf stable -C btsync

You can now either add /usr/local/bin/btsync to your PATH environment variable.

export PATH=$PATH:/usr/local/bin/btsync

or run the btsync binary right from that folder. We'll go with the first option as it requires less typing and is easier to remember.

Configuring Btsync

Btsync comes with a built-in web server which is used as the management interface for BitTorrent Sync. To be able to access the web interface, you need to create a configuration file. You can do that with the following command:

# btsync --dump-sample-config > btsync.config

Then edit the btsync.config file (webui section) with your preferred text editor, as follows:

"listen" : "0.0.0.0:8888",
"login" : "yourusername",
"password" : "yourpassword"

You can choose any username and password.

Feel free to check the README file in /usr/local/bin/btsync directory if you want to tweak the configuration further, but this will do for now.

Running Btsync for the First Time

As system administrators we believe in logs! So before we launch btsync, we will create a log file for btsync.

# touch /var/log/btsync.log

Finally it's time to start btsync:

# btsync --config /usr/local/bin/btsync/btsync.config --log /var/log/btsync.log

Now point your web browser to the IP address of the Linux server and the port where btsync is listening on (192.168.0.15:8888 in my case), and agree to the privacy policies, terms, and EULA:

and you will be taken to the home page of your btsync installation:

Click on Add a folder, and choose a directory in your file system that you want to share. In our example, we will use /btsync:

That's enough by now. Please install BitTorrent Sync on your Windows machine (or another Linux box, if you want) before proceeding.

Sharing Files with Btsync

The following screencast shows how to sync an existing folder in a Windows 8 machine [192.168.0.106]. After adding the desired folder, get its key, and add it in your Linux installation via the "Enter a key or link" menu (as shown in the previous image), and the sync will start:

Now repeat the process for other computers or devices; selecting a folder or files to share, and importing the corresponding key(s) in your "central" btsync installation via the web interface on your Linux server.

Auto-start Btsync as a Normal User

You will notice that the synced files in the screencast were created in the /btsync directory belonging to user and group 'root'. That is because we launched BitTorrent Sync manually as the superuser. However, under normal circumstances, you will want to have BitTorrent Sync start on boot and running as a non-privileged user (www-data or other special account created for that purpose, btsync user for example).

To do so, create a user called btsync, and add the following stanza to the /etc/rc.local file (before the exit 0 line):

sudo -u btsync /usr/local/bin/btsync/btsync --config /usr/local/bin/btsync/btsync.config --log /var/log/btsync.log

Finally, create the pid file:

# touch /usr/local/bin/btsync/.sync//sync.pid

and change the ownership of /usr/local/bin/btsync recursively:

# chown -R btsync:root /usr/local/bin/btsync

Now reboot and verify that btsync is running as the intended user:

Based on your chosen distribution, you may find other ways to enable btsync to start on boot. In this tutorial I chose the rc.local approach since it's distribution-agnostic.

Final Remarks

As you can see, BitTorrent Sync is almost like server-less Dropbox for you. I said "almost" because of this: When you sync between devices on the same local network, sync happens directly between two devices. However, if you try to sync across different networks, and the devices to be paired are behind restrictive firewalls, there is a chance that the sync traffic goes through a third-party relay server operated by BitTorrent. While they claim that the traffic is AES-encrypted, you may still not want this to happen. For your privacy, be sure to turn off relay/tracker server options in every folder that you are sharing.

Hope it helps! Happy syncing!

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work. When he's not typing commands or writing code or articles, he enjoys telling bedtime stories with his wife to his two little daughters and playing with them, the great pleasure of his life.

11 thoughts on “How to share files between computers over network with btsync

  1. Nice tool, but you might also want to have a look at git-annex, which also synchronize between different computers.
    https://git-annex.branchable.com/

    Really nice tool, actually, where you can use many different cloud storages, and your own, to sync files to different computers. And you don't need to store every file on all devices.

  2. Struggling to understand the value of this. I get the point of torrents if you are trying to download a large file and you can leverage many uploaders to maximize your download speed but if you're only syncing your own stuff between a couple of devices then something like Owncloud seems a better approach

    • This is a good point. I think in case of btsync, the value is not so much in the sync speed, but rather in the automatic NAT traversal capability of the BT protocol. So using btsync you can sync devices across different NATs, which you cannot do with owncloud.

  3. 1) You shouldn't allow a closed-source program to run on your system,
    especially as the root user. I 'm pretty sure that btsync can be
    installed so as to run as another user.

    2) Consider replacing

    ps -ef | grep btsync | grep -v grep

    with

    ps -ef | grep btsyn

    • @Ron,
      The point in using grep -v grep is to only show btsync in the output of ps -ef. If you omit grep -v grep you'll also get ps in the results.

      In addition, I never suggested btsync should run as root. Actually, I explained that it should run as a non-privileged user, btsync in this case. Did you read to the bottom of the article?

  4. Where's the source code? Oh, wait...it's not available. TROJAN HORSE!

    There's no way I would recommend using this "tool" unless the source code came with it. From what we know, it spies on you through your browser and "phones home" with whatever profile it's collected about you. I'll stick with rsync across an SSH tunnel, thanks. For Microsoft Windows users, you're already pwn3d anyway, so maybe it doesn't matter so much to you. But Free Software users (GNU/Linux, *BSD) should know better.

    --SYG

  5. @Guido and @Sum,
    I am also a huge advocate of Free Software.
    However, in all honesty, I do not understand why you're so sure about btsync being a trojan horse. Or are you guys calling it that because it's closed-source?

Leave a comment

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