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:
sudo add-apt-repository ppa:qbittorrent-team/qbittorrent-stable
Then update your repository info and install qbittorrent-nox
sudo apt update sudo apt install qbittorrent-nox –y
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.
sudo adduser --system qbittorrent-user
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:
cd /etc/system/sytem/ sudo nano qbittorrent-nox.service
then enter the commands below
[Unit] Description=qBittorrent Daemon Service After=network.target [Service] User=qbittorrent-user ExecStart=/usr/bin/qbittorrent-nox ExecStop=/usr/bin/killall -w qbittorrent-nox [Install] WantedBy=multi-user.target
Save and Exit (Ctrl + O, Ctrl + X) the file
Update the system with the new daemon by entering
sudo systemctl daemon-reload
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:
*** Legal Notice *** qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility. No further notices will be issued. Press 'y' key to accept and continue...
Press y and Enter, and the following will appear:
******** Information ******** To control qBittorrent, access the Web UI at http://localhost:8080 The Web UI administrator user name is: admin The Web UI administrator password is still the default one: adminadmin This is a security risk, please consider changing your password from program preferences.
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
sudo systemctl start qbittorrent-nox.service
And verify that it is running
sudo systemctl status qbittorrent-nox.service
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
sudo systemctl enable qbittorrent-nox.service
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.
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
sudo apt purge qbittorrent-nox
Then remove the user account
sudo deluser --remove-home qbittorrent-user
You can also remove the startup script
sudo rm /etc/system/system/qittorrent-nox.service