Cinan's world

GNU/Linux & free software, howtos, web development, scripts and other geek stuff

Download Torrents on Your Server

tl;dr

  • How to setup Transmission web client on your Linux server
  • Firewall setup
  • Email notifications setup

Why am I doing this?

Recently I’ve needed to download some stuff from torrentz. I have quite unstable and slow internet connection at home, so I’ve decided to download the stuff to my server and later transfer it to my laptop via rsync (with transfer resume enabled and high compression ratio).

Choose a torrent client

There are many torrent clients suitable for headless Linux server (so they don’t need X.Org server and allow remote access). I’ve picked out Transmission. It looks easy to configure & use, supports magnet links, is lightweight, has web interface and is actively developed.

Install & configure

If your Linux distribution provides split Transmission package, you need just transmission-cli or transmission-daemon (simply, ignore GTK or Qt packages).

After installation edit Transmission daemon configuration file (may be located here /var/lib/transmission/.config/transmission-daemon/settings.json or here /etc/init.d/transmission-daemon/settings.json).

Interesting options you’ll probably need to edit are these:

  • encryption: 2 (Require encrypted connections)
  • rpc-enabled: true (Required for Transmission web client)
  • rpc-password: “” (Put some password, after transmission-daemon restart it will be hashed)
  • rpc-port: 9091
  • rpc-whitelist-enabled: false (if you have dynamic public IP address you want disable this option)
  • umask: 0 (Give access to downloaded files to everybody – files have read & write permissions for owner, group and others)

If you’re a bitch and want to disable seeding right after torrent download is completed, set ratio-limit to 0 and ratio-limit-enabled to true.

Try web interface

You don’t need any HTTP server like Apache or Nginx, just go to http://your_domain:9091. Enter login username (by default empty) and password. That’s all.

Open ports in your firewall

Find peer-port option in transmission config. Open this port in /etc/iptables/iptables.rules:

-A INPUT -p tcp -m tcp --dport 51413 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 51413 -j ACCEPT
-A OUTPUT -p udp -m udp --dport 80:60000 -j ACCEPT

Port 51413 has to be opened otherwise Transmission cannot download and upload data. Also I’ve opened a range of UDP ports because of magnet links.

Hey! Downloading is finished!

Transmission daemon can run any script after downloads are completed. First I’ve set script-torrent-done-enabled to true and inserted full path to the script into script-torrent-done-filename option.

Here’s my script:

1
2
#!/usr/bin/env bash
echo "'$TR_TORRENT_NAME' is finished!" | gnu-mail -a "From: cinan.remote@gmail.com" -s "Torrent download finished" cinan6@gmail.com

Comments