Merge pull request #2444 from martin2011qi/master

[translated] 20150215 How to share files between computers over network with btsync
This commit is contained in:
Xingyu.Wang 2015-02-24 20:08:50 +08:00
commit fc9d95dcc5
2 changed files with 135 additions and 138 deletions

View File

@ -1,138 +0,0 @@
translating by martin.
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][1] and [iOS][2]. 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][3]. 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
![](https://farm9.staticflickr.com/8635/15895277773_8acf317e3c_c.jpg)
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
![](https://farm8.staticflickr.com/7306/16329173869_7dc8b64a39_b.jpg)
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.
![](https://farm9.staticflickr.com/8599/15895277793_da63841433_b.jpg)
![](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
![](https://farm8.staticflickr.com/7288/16327720298_ccf2cbedea_c.jpg)
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:
![](https://farm9.staticflickr.com/8597/16327720318_d52551fc44_b.jpg)
and you will be taken to the home page of your btsync installation:
![](https://farm8.staticflickr.com/7412/16329544687_9a174527d8_c.jpg)
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:
![](https://farm8.staticflickr.com/7407/16515452485_e25ded559f_b.jpg)
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:
注释youtube视频
<iframe width="615" height="346" frameborder="0" allowfullscreen="" src="http://www.youtube.com/embed/f7kLM0lAqF4?feature=oembed"></iframe>
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:
![](https://farm9.staticflickr.com/8647/16327988660_644f6d4505_c.jpg)
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][4], 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!
--------------------------------------------------------------------------------
via: http://xmodulo.com/share-files-between-computers-over-network.html
作者:[Gabriel Cánepa][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/gabriel
[1]:https://play.google.com/store/apps/details?id=com.bittorrent.sync
[2]:https://itunes.apple.com/us/app/bittorrent-sync/id665156116
[3]:http://www.getsync.com/
[4]:http://www.getsync.com/tech-specs

View File

@ -0,0 +1,135 @@
如何使用btsync通过网络实现电脑间文件共享
================================================================================
如果你是使用各式设备在网上工作的这类人,我相信你肯定需要一个在不同设备间同步文件及目录的方法,至少是非常渴望有这种功能。
BitTorrent Sync简称btsync是一个基于BitTorrent著名P2P文件分享协议的免费跨平台同步工具。与传统BitTorrent客户端不同的是btsync用于传输加密和访问授权的是不同操作系统及设备中自动生成的键。
更具体点当你想要通过btsync共享一些文件或文件夹相应的读/写键所谓的秘密编码已经创建。这些键将会通过不同的途径例如HTTPS链接电子邮件二维码等被分享。一旦两台设备通过一个键配对成功链接内容将会直接在其间同步。如果没有事先设置传输将不会有文件大小和速度的限制。你可以在btsync中创建账号以此来创建和管理通过网络分享的键和文件。
BitTorrent Sync可以在许多的操作系统上运行包括LinuxMacOS XWindows在 [Android][1]和[iOS][2]上也可以使用。在这里我们将教你在Linux环境一台家用服务器与Windows环境一台笔记本电脑之间如何使用BitTorrent Sync来同步文件。
### Linux下安装btsync ###
BitTorrent Sync可以在[项目主页][3]直接下载。由于Windows版本的BitTorrent Syn安装起来十分简单所以我们假设笔记本上已经安装了。我们把焦点放到Linux服务器上的安装和配置。
在下载页面中选择你的系统架构右键相应链接选择复制连接地址或者简单的依靠浏览器判断将链接粘贴到在终端中用wget下载如下
**64位Linux:**
# wget http://download.getsyncapp.com/endpoint/btsync/os/linux-x64/track/stable
**32位Linux:**
# wget http://download.getsyncapp.com/endpoint/btsync/os/linux-i386/track/stable
![](https://farm9.staticflickr.com/8635/15895277773_8acf317e3c_c.jpg)
下载完成后,把包中内容解压到你专门创建的目录中,为了完成这些:
# cd /usr/local/bin
# mkdir btsync
# tar xzf stable -C btsync
![](https://farm8.staticflickr.com/7306/16329173869_7dc8b64a39_b.jpg)
现在你可以选择将/usr/local/bin/btsync添加到环境变量PATH中去。
export PATH=$PATH:/usr/local/bin/btsync
或者在在该文件夹中运行btsync的二进制文件。我们推荐使用第一种方式虽需要少量的输入但更容易记忆。
### 配置Btsync ###
Btsync带有一个内置的网络服务器被用作其管理接口。想要使用这个接口你需要创建一个配置文件。你可以使用以下命令来创建
# btsync --dump-sample-config > btsync.config
然后使用你最常用的编辑器对btsync.config文件的webui部分作以下修改
"listen" : "0.0.0.0:8888",
"login" : "yourusername",
"password" : "yourpassword"
你可以选择任何用户名和密码。
![](https://farm9.staticflickr.com/8599/15895277793_da63841433_b.jpg)
### 第一次运行btsync ###
作为一个系统的最高执行者我们需要依赖日志文件所以在我们启动btsync之前我们将先为btsync创建一个日志文件。
# touch /var/log/btsync.log
最后让我们开启btsync
# btsync --config /usr/local/bin/btsync/btsync.config --log /var/log/btsync.log
![](https://farm8.staticflickr.com/7288/16327720298_ccf2cbedea_c.jpg)
现在在你的浏览器中输入正在运行btsync监听的服务器IP地址和端口我这是192.168.0.15:8888同意隐私政策条款和最终用户许可协议
![](https://farm9.staticflickr.com/8597/16327720318_d52551fc44_b.jpg)
这样页面就会转到你安装的btsync主页
![](https://farm8.staticflickr.com/7412/16329544687_9a174527d8_c.jpg)
点击添加文件夹并在你的文件系统中选择一个你想要分享的目录,在我们的例子中,我们使用的是/btsync
![](https://farm8.staticflickr.com/7407/16515452485_e25ded559f_b.jpg)
现在这样就够了。在运行接下来的步骤之前请先在Windows主机或你想使用的其他Linux设备上安装BitTorrent Sync。
### Btsync分享文件 ###
下方的视频将会展示如何在安装Windows8的电脑[192.168.0.106]上分享现有的文件夹。在添加好想要同步的文件夹后你会得到它的键通过“Enter a key or link”菜单上面的图已经展示过了添加到你安装到的Linux机器上并开始同步
注释youtube视频
<iframe width="615" height="346" frameborder="0" allowfullscreen="" src="http://www.youtube.com/embed/f7kLM0lAqF4?feature=oembed"></iframe>
现在用别的设备试试吧找一个想要分享的文件夹或是一些文件并通过Linux服务器的网络接口将键导入到你安装的“核心”btsync中。
### 使用常规用户开机自动运行btsync ###
你们可能注意到了,视频中在同步文件时是使用'root'组的用户创建/btsync目录的。那是因为我们使用超级用户手动启动BitTorrent Sync的原因。在通常情况下你会希望它开机自动使用无权限用户www_data或是专门为此创建的账户例如btsync启动。
所以我们创建了一个叫做btsync的用户并在/etc/rc.local文件exit 0行前添加如下字段
sudo -u btsync /usr/local/bin/btsync/btsync --config /usr/local/bin/btsync/btsync.config --log /var/log/btsync.log
最后创建pid文件
# touch /usr/local/bin/btsync/.sync//sync.pid
并递归更改/usr/local/bin/btsync的所属用户
# chown -R btsync:root /usr/local/bin/btsync
现在重启试试看看btsync是否正在由预期中的用户运行
Now reboot and verify that btsync is running as the intended user:
![](https://farm9.staticflickr.com/8647/16327988660_644f6d4505_c.jpg)
基于你选择的发行版不同你可能找到不同的方式来开机自启动btsync。在本教程中我选择rc.local的方式是因为它在不同发行版中都可使用。
### 尾注 ###
如你所见BitTorrent Sync对你几乎就像一个无服务器的Dropbox。我说“几乎”的原因是当你在局域网内同步数据时同步在两个设备之间直接进行。然而如果你想要跨网段同步数据并且你的设备可能要穿过防火墙的限制来配对那就只能通过一个提供BitTorrent的第三方中继服务器来完成同步传输。虽然声称传输经过 [AES加密][4],你还是可能遇到不想放生的状况。为了你的隐私着想,务必在你共享的每个文件夹中关掉中继/跟踪选项。
希望这些对你有用!分享愉快!
--------------------------------------------------------------------------------
via: http://xmodulo.com/share-files-between-computers-over-network.html
作者:[Gabriel Cánepa][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/gabriel
[1]:https://play.google.com/store/apps/details?id=com.bittorrent.sync
[2]:https://itunes.apple.com/us/app/bittorrent-sync/id665156116
[3]:http://www.getsync.com/
[4]:http://www.getsync.com/tech-specs