Command line torrent server using rTorrent

  Last modified on Sunday 18 June 2017

PROJECT: Home Server #10 .: A text-based BitTorrent client that - combined with tmux - makes a cool lightweight torrent server.

Let's go!

I can ssh into my home server, start a tmux session and create multiple windows, run rTorrent in a window to start seeding a Linux iso, detach from session and server, and return later to find everything in place and the iso uploading.

0. Install

$ sudo apt install rtorrent
$ mkdir -p ~/rtorrent/config.d

1. Start and config

Create an rTorrent executable startup script ~/rtorrent/start with the details provided in the rTorrent cookbook.

Download and save the default configuration template to ~/.rtorrentrc. Open the file and comment out (deactivate) the dht and watch directory settings ...

[...]
#dht.mode.set = disable
#protocol.pex.set = no
#trackers.use_udp.set = no
[...]
#schedule2 = watch_start, 10, 10, ((load.start, (cat, (cfg.watch), "start/*.torrent")))
#schedule2 = watch_load, 11, 10, ((load.normal, (cat, (cfg.watch), "load/*.torrent")))

Remember to configure port forwarding on the home router firewall for ports network.port_range.set (default 50000) and dht.port.set (configured below).

2. Config fragments

Customize the config by creating some drop in config fragments in ~/rtorrent/config.d. For my setup I create fragments to establish bandwidth quotas, enable dht and require encrypted traffic, and set a directory that rTorrent watches for new torrent files ...

  • bandwidth.rc
print="Global bandwidth .: download_rate = 100 / upload_rate = 20"
throttle.global_down.max_rate.set_kb = 100
throttle.global_up.max_rate.set_kb = 20
  • dht.rc
print="DHT support = auto"
dht.mode.set = auto
dht.port.set = 6881
protocol.pex.set = yes
trackers.use_udp.set = yes
  • encryption.rc
print="Encryption = required"
encryption = require,require_RC4,allow_incoming,try_outgoing
  • watch.rc
print="Watch directory enabled."
schedule2 = watch_directory,5,5, ((load.start, (cat, (cfg.watch), "*.torrent")))
schedule2 = untied_directory,5,5,stop_untied=
schedule2 = tied_directory,5,5,start_tied=

3. Run

Launch ~/rtorrent/start and a basic rTorrent setup is now up and running. Check out the cheatsheet for navigating around the interface and the rTorrent docs and the torrent client's entry on the Arch Wiki for details and ideas for more advanced configs.

Happy hacking!

More • rtorrentshellnetworkdebianlinux