RTorrent & RuTorrent Setup Guide
This post inspired by Jesse Schoff's guidance with some updates and edits since I tried this yesterday and there were unmentioned updates and edits.
Distributions
Installation and configuration of these applications for different distributions of Linux is largely the same, but this guide is written specifically for Debian 8.x and Ubuntu 16.x.
Note
- The guide will use <username>, <server.address> and <port> placeholders as the username for ssh login, ip address of the server and port number for ssh access respectively. To avoid headaches, use only lowercase alpha characters for the username. Your server address can be an IP address or FQDN. Do not include the protocol or trailing slash. Do not make up a non-existent or unconfigured hostname. Use the server IP if in doubt. Examples: 123.123.123.123 or serveraddress.com. Choose a port for SSH. Somewhere between 10001-65535 is likely to be conflict free.
- Any updates or edits kindly reply and I will update this post.
Preparation
Start by updating and upgrading the operating system:
Code:
apt-get update && apt-get upgrade
Secure Your Environment
You likely know you shouldn't operate as root, whether you know why or not. If you want to know more, there are lots of resources. If you're starting from scratch, and this machine will be principally dedicated to rTorrent and ruTorrent, having a security hardened system likely isn't a major concern. But, if you're learning, you may as well learn with best practices in mind.
Create a new user:
Install sudo:
Code:
apt-get install sudo
Install nano (may already be installed):
Code:
apt-get update && apt-get install nano
Open the super users list:
Add your username to grant yourself super user privileges:
Code:
# User privilege specification
root ALL=(ALL:ALL) ALL
<username> ALL=(ALL:ALL) ALL
Open SSH configuration for editing:
Code:
nano /etc/ssh/sshd_config
Let's edit the SSH configuration to make your server a little more secure. The following adjustments will...
- Change the default SSH port to make it more difficult for attackers to access.
- Disallow root login while only allowing your user account to login via SSH. An attacker would now have to guess the port and username.
- Turn off x11 forwarding and DNS for added security.
This is why we change the SSH port...
http://www.sb-innovation.de/attachme...chmentid=18781
Modify the following lines in sshd_config:
Code:
Port <port>
PermitRootLogin no
X11Forwarding no
Add the following lines to the bottom of sshd_config:
Code:
UseDNS no
AllowUsers <username>
Restart SSH daemon:
Open a new terminal and test logging in with your newly created user + modified SSH port. If it works, close the root session and continue with your new user account, if not, check settings in previous steps with the root terminal.
From now on, we will prepend sudo to many commands. This will execute the command with super user privileges, a requisite for modifying any files not owned by your user account.
Installing rTorrent + LibTorrent + XML-RPC
Install Dependencies
Paste this entire line into the terminal to install each dependency.
Code:
sudo apt-get install -y build-essential subversion autoconf screen g++ gcc ntp curl comerr-dev pkg-config cfv libtool libssl-dev libncurses5-dev ncurses-term libsigc++-2.0-dev libcppunit-dev libcurl3 libcurl4-openssl-dev git
-y makes the operation assume "yes" as answer to all prompts and run non-interactively. More information.
Install XML-RPC
From the project homepage:
Quote:
"XML-RPC is a quick-and-easy way to make procedure calls over the Internet. It converts the procedure call into an XML document, sends it to a remote server using HTTP, and gets back the response as XML."
XML-RPC is required for communication between rTorrent and ruTorrent.
Code:
svn co -q https://svn.code.sf.net/p/xmlrpc-c/code/stable /tmp/xmlrpc-c
cd /tmp/xmlrpc-c
./configure --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server
make -j2
sudo make install
Each of these commands should be executed individually. (Don't copy and paste the entire block; input them line by line.)
In the commands above we've...
- downloaded and unpacked XML-RPC into its own temporary directory.
- configured XML-RPC while disabling features that we don't need for rtorrent/rutorrent.
- used the -j2 modifier for make, forcing it to recompile using two threads. If you have a dual- or quad-core CPU, you can increase this number to speed up the compiling process (to a degree).
Install LibTorrent
LibTorrent is the library on which the rTorrent client runs.
Before beginning this section, navigate to Rtorrent by rakshasa in your browser to find the latest version of the library. Update the filename in the commands below to account for the version of LibTorrent you'd like to use. Make sure any communities you belong to have the torrent client you choose to use whitelisted.
Code:
cd /tmp
curl http://rtorrent.net/downloads/libtorrent-0.13.6.tar.gz | tar xz
cd libtorrent-0.13.6
./autogen.sh
./configure
make -j2
sudo make install
Install rTorrent
Just as with the previous section, navigate to Rtorrent by rakshasa in your browser to find the latest version of the client. Update the filename in the commands below to account for the version of rTorrent you'd like to use. Make sure any communities you belong to have the torrent client you choose to use whitelisted.
Code:
cd /tmp
curl http://rtorrent.net/downloads/rtorrent-0.9.6.tar.gz | tar xz
cd rtorrent-0.9.6
./autogen.sh
./configure --with-xmlrpc-c
make -j2
sudo make install
sudo ldconfig
Make rTorrent directories and change their owner:
Code:
sudo mkdir -p /home/downloads/{.session,~watch}
sudo chown -R <username>:<username> /home/downloads
- The -p flag makes nested directories. I.e., it will create the directory downloads and nest .session and ~watch within it.
- The -R flag recursively applies chown to the target's subfolders.
Configure rTorrent
To configure rTorrent, you need to modify the file ~/.rtorrent.rc. You can either modify each line individually, or paste the preconfigured file provided below.
Option One: Copy and Paste Preconfigured .rtorrent.rc File
Create the file in your home directory:
Code:
nano ~/.rtorrent.rc
Paste the contents of following file into the .rtorrent.rc file you just created in Nano.
Code:
# Maximum and minimum number of peers to connect to per torrent.
min_peers = 40
max_peers = 100
# Same as above but for seeding completed torrents (-1 = same as downloading)
min_peers_seed = 25
max_peers_seed = 60
# Maximum number of simultaneous uploads per torrent.
max_uploads = 30
# Global upload and download rate in KiB. "0" for unlimited.
#download_rate = 0
#upload_rate = 0
# Default directory to save the downloaded torrents.
directory = /home/downloads
# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session = /home/downloads/.session
# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=/home/downloads/~watch/*.torrent
# Close torrents when diskspace is low.
schedule = low_diskspace,5,60,close_low_diskspace=10240M
# The ip address reported to the tracker.
#ip = 127.0.0.1
#ip = rakshasa.no
# The ip address the listening socket and outgoing connections is
# bound to.
#bind = 127.0.0.1
#bind = rakshasa.no
# Port range to use for listening.
port_range = 55950-56000
# Start opening ports at a random position within the port range.
port_random = yes
# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
check_hash = yes
# Set whether the client should try to connect to UDP trackers.
use_udp_trackers = yes
# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa
# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
encryption = allow_incoming,enable_retry,prefer_plaintext
# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
dht = disable
# UDP port to use for DHT.
#
# dht_port = 6881
# Enable peer exchange (for torrents not marked private)
#
peer_exchange = no
scgi_port = 127.0.0.1:5000
Option Two: Modify .rtorrent.rc Manually
Copy .rtorrent.rc to your home directory, and then open the file for editing. Change the directory name to match the version of the package you downloaded.
Code:
cp ~/rtorrent-0.9.6/doc/rtorrent.rc ~/.rtorrent.rc
nano ~/.rtorrent.rc
Change or add the following lines accordingly:
Code:
directory = /home/downloads
session = /home/downloads/.session
schedule = watch_directory,5,5,load_start=/home/downloads/~watch/*.torrent
schedule = low_diskspace,5,60,close_low_diskspace=10240M
port_range = 55950-56000
port_random = yes
check_hash = yes
use_udp_trackers = yes
encryption = allow_incoming,enable_retry,prefer_plaintext
dht = disable
peer_exchange = no
scgi_port = 127.0.0.1:5000
Modify these values as you see fit. Of note, these lines...
- Define the default downloads directory as /home/downloads.
- Tell rTorrent where to 'watch' for new torrent files that are uploaded to the server, and to not add them if there is less than 10GB of disk space available.
- Disable DHT and peer exchange, which is a requirement of most private trackers.
- Define the scgi port for rTorrent
Let's check to make sure rTorrent starts.
You won't anything interesting; if it opens, we're good to go. Close rTorrent by pressing Ctrl+Q.
Next, we'll start rTorrent in a screen session that will allow it to continue running in the background.
Code:
screen -S rtorrent -fa -d -m rtorrent
What do those modifiers mean?
-S rtorrent Screen session name: rtorrent
-d -m Start screen in detached mode; exit if session terminates
-fa Flow control: automatic