Install Torrent Client

Once very good use for your server is to have a torrent server running on it. As you will typically be leaving the server running for long periods, it is ideal for downloading large files or ones which are slow to download. In this article we will go through how to download and install the qBittorrent server and have it running constantly in the background.

There are two version of qBittorrent available: one for desktops and one for servers. As the desktop display on linux systems is called X Windows, the server version we are going to install, which uses a web interface instead, is called qbittorrent-nox, i.e. qbittorrent with no X display.

qBittorrent is available in the standard Ubuntu software repositories, but to get the most up to date stable packages, they advise adding their repositories to your system by entering the command:

Then update your repository info and install qbittorrent-nox

Add New User

For security purposes it is always good to have online services running under their own user account. This way, if someone found a way to breach your server using a vulnerability or flaw in the service, they would be very limited in what they could do on your server. Create a new user with a home directory.

Adding the ‑‑system flag tells your Ubuntu server that this account is a system account and not one which is intended to be logged onto. The server will set it up without a login.

Create the qBittorrent Service

Next you need to create the service which will be running. Services in Ubuntu 18.04 are run and managed using Systemd. Go to the Systemd directory and create a new file:

then enter the commands below

Save and Exit (Ctrl + O, Ctrl + X) the file

Update the system with the new daemon by entering

Set up the Configuration

When you run qBittorrent for the first time, there is a disclaimer which must be accepted. To do this, run:

and you should see:

Press y and Enter, and the following will appear:

You can access qbittorrent now by going to your servers IP address and port 8080, and entering the username and password shown.

Please note, if you are running a firewall, you will need to allow access to this port.

To get back to a command prompt and complete the service, press Ctrl + C.

Finish Setting up the Service

While you can run qbittorrent-nox from the command line, as soon as you close down the shell session it will end. What you want is for it to be running as a service on the server. This way it is always running in the background and starts automatically when the server is booted.

First, lets start the new service

And verify that it is running

You will need to quit out of the status screen by pressing q.

Finally enable the qbittorrent service so it starts up automatically when the server is booted up

First Log In

When you first log in to qBittorrent, use the default username (admin) and password (adminadmin). For security, these must be changed right away. Go to Tools > Options > Web UI. Under the Authentication section, create a new username and password.

The port 8080 is a commonly used test port for applications, so it would be good to give qBittorrent its own distinct port. On the Web UI menu, under the Web User Interface section, change the port to something new. It must be above 1000 and less then 65535. Be sure to set your firewall rules to block traffic to 8080 again and allow traffic to reach the new port.

Finally, set your download folder for completed torrents by going to the Downloads tab. Then, under Saving Management, set Default Torrent Management Mode to Automatic, and set Default Save Path also.

In Closing…

That should be it! Be sure to allow a firewall rule to the port you are running qBittorrent on, and change the default username and password.

To begin using qBittorrent to download content, take a look at our post on searching and downloading torrents using qBittorrent.

It is important that the user has a home directory, as you need to accept a disclaimer when first running qbottorrent. This is noted in a config file saved to /home/qbittorrent-user/.config/qBittorrent. When I first created the qbittorrent-user account, I used the ‑‑no-create-home flag, which doesn’t create a home directory. This created problems with running the service though, which I eventually traced back to the config file.

If you do hit difficulties, stepping back and undoing your steps is easy enough. Firstly uninstall the application

Then remove the user account

You can also remove the startup script