How to set up transmission-daemon on a Raspberry Pi and control it via web interface
Introduction
Transmission is probably the most famous torrent client in the Gnu/Linux world, and it’s very often used even on other operating systems. It’s really easy to use, and its graphical interface is very intuitive; however in this tutorial we will see how to install transmission-daemon
and run transmission on a headless machine: that’s an ideal setup to create a “Torrent-box”, using for example a Raspberry Pi, to reduce power usage.
Once installed and configured, we will be able to manage the application using the web interface. For the sake of this tutorial I will install transmission-daemon on a Raspberry Pi, using the Raspbian operating system, however the same instructions should work on Ubuntu and Debian.
Step 1 – Installation
The first thing we need to do is to install the needed packages on our system: this won’t take a lot of time since transmission is available in the repository of all the most famous linux distributions. Raspbian, the Raspberry Pi operating system based on debian, makes no exception:
$ sudo apt-get update && sudo apt-get install transmission-daemon
After confirmation the package and its dependencies will be installed on our system. The transmission-daemon
, will be also automatically activated and enabled at boot, however for our next step, the configuration of the application, we need to temporary stop it, so at this point we should run:
$ sudo systemctl stop transmission-daemon
Step 2 – Setup
In order to run the application correctly we should, at this point, edit the configuration file. Transmission-daemon settings are stored in a json
file: /etc/transmission-daemon/settings.json
. We should open it with our favorite editor and administrative privileges. This is its content:
As you can see, many options can be tweaked, however we are going to focus on the most important ones for us at the moment.
The first line which should get our attention, is on Line 15, are download_dir
. This is quite self explanatory: via this option we can setup the directory in which the files will be downloaded. The default destination is /var/lib/transmission-daemon/downloads
: this directory will host both the complete and incomplete downloads.
In case we want to differentiate them, and host the incomplete ones separately, we must set the incomplete-dir-enabled
option to true
on Line 24The path in which the incomplete downloads will be stored is set via the incomplete-dir
option, and by default is /var/lib/transmission-daemon/Downloads.
The next, very important options we should change are rpc-password
and rpc-username
located respectively on Lines 51 and 54 of the configuration file. Using them, we can set the “login” data that will be used to access the transmission web interface: by default the value of both is “transmission”. The value we see on rpc-password
in the configuration file is the result of the hashing of the plain text password: we insert our password in the field, and it will be automatically hashed once the daemon starts. Be sure to change the defaults and use safe and possibly easy to remember values for these settings.
Other options of great importance are rpc-port
and rpc-url,
set respectively to 9091
and /transmission/
on Lines 52 and 53. The former is the port that used to connect to the web interface, and the latter is the url used to reach the interface itself. It’s quite safe to use the default values, and it’s important to remember the port number, since we need to change the firewall so it will allow connections via this port.
Speaking of ports, the default transmission peer-port is 51413
, as defined on Line 32. Opening this port on the firewall (and allowing port forwarding in the router) is not strictly necessary for the applications to work correctly, however it is needed for it to work in active
mode, and so to be able to connect to more peers.
Finally, two other important options are rpc-whitelist
and rpc-whitelist-enabled
. When the latter is enabled, on Line 56 is possible to restrict the hosts from which the connection to the web interface will be allowed, by passing a list of comma-separated allowed IPs. Say for example we want to allow access from the host with the 192.168.1.40 Ip, all we would need to do is add the address to the whitelist
:
"rpc-whitelist": "127.0.0.1,192.168.1.40"
Change the configuration as you like, then close and save the file. The next step is to configure the firewall.
Step 3 – Firewall configuration
For the sake of this tutorial I will assume the use of the ufw
firewall. What we need to do is to enable ports 9091
and 51413
to respectively being able to access the web interface, and work in active mode. To achieve the latter task, we must also enable port forwarding on the router (or use UPnP, which I personally don’t trust). This step, however is not covered in this tutorial, since the exact procedure to use varies depending on the router model. It is not, however a difficult task.
To enable the ports using ufw, we run:
$ sudo ufw allow 9091,51413/tcp
We are done. Now we need to restart the transmission-daemon:
$ sudo systemctl start transmission-daemon
If no error are displayed, we should be good to go.
Step 4 – Access the web interface
We can finally use the web interface. Fire up a web browser and navigate to the ip of the machine on which transmission-daemon have been installed, using port 9091. For example, let’s suppose that the address of the machine we configured to run transmission is 192.168.1.39, we would use http://192.168.1.39:9091/transmission
.
If all goes well, we will be asked to insert the username and password set in the configuration file. Once we login successfully, we will be able to use the transmission web interface!
You can see transmission is working correctly, and it’s downloading a torrent in the default destination.