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.

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...

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:

Code:

service ssh reload

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.

"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."

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.

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.

- 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.

Code:

rtorrent

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.

ServerTokens Prod will prevent Apache from reporting its version number, and ServerSignature Off will disable the server signature displayed in Apache error messages. Small steps to harden your system.

Restart Apache

Code:

sudo service apache2 restart

Now, let's confirm that Apache and PHP are working.

Code:

echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php

The previous command created a file called info.php in the web root containing the function phpinfo(), which, if everything is functioning properly, should print a large table of information detailing your server's PHP settings.

Fill in the fields as prompted, or leave them blank (excepting the CN field). Be sure to input something for the CN (Common Name) field. Typically this is your server's hostname, but if you have a domain pointed to your server, you may use that instead.

Now, change the permissions for the newly created certificate, as some programs will refuse to load these certificates if permissions are set wrong.

Code:

sudo chmod 600 /etc/apache2/ssl/apache.pem

Configure Apache Access

Open Apache's default configuration:

Code:

sudo nano etc/apache2/sites-available/000-default.conf

Modify as follows, or replace the whole document, to enable SSL on port 443 and to setup Auth Digest for the rutorrent directory:

Confirm that Apache and SSL are working by navigating to your server in a browser with the https:// prefix: https://<server.address>

You will likely receive a warning from your browser suggesting that the site is insecure. This is because of our self-signed certificate; ignore it and proceed. You should see a page containing the text, "It works!" Or with new versions of Ubuntu, you'll see the "Apache2 Ubuntu Default Page."

Optional: Modify PHP Settings

If you ever find yourself uploading one or two dozen torrents at a time, you may want to adjust the PHP settings to allow for larger file uploads. First, create a new phpinfo() file. There are other, quicker ways to find the active php.ini file, but this is a surefire method that won't leave you editing one of the inactive files.

Code:

echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php

Go to <server.address>/info.php in your browser.

Find the line that says Loaded Configuration file and then copy and paste its location in the following command, replacing the underlined string:

Code:

sudo nano /etc/php5/apache2/php.ini

Use Ctrl+W in Nano to find and modify the following lines:

Code:

upload_max_filesize = 64M
max_file_uploads = 200
post_max_size = 128M

You may set these values to whatever you like. Remove the file info.php to reduce security risks.

Download ruTorrent from the project's Github repository, remove the packaged plugins directory, then replace it with the plugins from the repository. The following commands will download the latest versions of ruTorrent and plugins. No need to find the latest versions like in previous steps.

- Changed the error log filename to differentiate it from other error logs.
- Restricted the ruTorrent interface to /home/downloads.
- Defined the paths to ruTorrent dependencies.

Configure ruTorrent Plugins

ruTorrent has extended functionality beyond basic interface with rTorrent via a robust set of plugins. The plugins.ini file allows you to either hardcode an on/off state for individual plugins, or set them as user-defined, which allows you to determine their state within the ruTorrent web GUI.

This alphabetized version of plugins.ini enables all of the (subjectively) most useful plugins, and the additional optional plugins you can choose to install later in this guide. Enable/disable plugins as you see fit (the more plugins enabled, the longer ruTorrent will take to load), and if you don't know what something does, leave it set as user-defined, and explore the features in the web GUI.

Now let's create a username/password for ruTorrent. This is a different set of credentials than the SSH user account we created at the beginning of this process. It's more secure to pick different credentials than those you chose previously, but less convenient. It's your choice.

Code:

sudo htdigest -c /etc/apache2/.htpasswd rutorrent <username>

Status Report

You've now completed all the steps to run rTorrent and ruTorrent on your server. You can stop here, or add additional functionality to ruTorrent or to your server, like the ability to stream media to your local devices, and automatically download torrents that match custom filter rules.

Before we go any further, verify that everything is working as expected. It's easier to fix problems now with fewer components to troubleshoot.

Who Said Thanks:

Let us say a plugin like Tracklabels isn't working which is responsible for trackers tab and icons auto labeling then you simply remove the plugin folder and re-download it after setting the plugin as enabled and still not working.

1) To set the plugin as enabled and confirm it's not working look to the steps above of editing the file