Why?
While most of our time on the Internet is spent IM’ing, e-mail, or just browsing the Web, you may run in to situations when you need to do some powerful file transfers. If you use a laptop, you’re use to getting up, suspending your laptop, and running out the door all of the time. But, sometimes you know you just need something dedicated to get work done. You’ll need a solution to retrieve files and serve data when you need it. In this guide, you’ll learn how to set a small headless Ubuntu server used to retrieve BitTorrent files, while even saving them to a external USB hard drive that can be disconnected on the go. You even discover how to remotely administer your server from the Web using SSH, VNC, and an intuitive HTML UI, while being able to retrieve files while you’re away from home.
This tutorial takes for granted you have a spare computer laying around. Building a computer is out of the scope of this article.
The OS Installation
Installing Ubuntu
We’ll be doing a basic Ubuntu Linux installation. Ubuntu is free operating system based on the Gnome desktop and the Linux kernel. But, “Isn’t this suppose to be a headless server?” you may ask. Why don’t we just do a server installation? Well, you could, but you spend more time later on installing the X-server packages needed to configure our BitTorrent client. Besides, you’re not tweaking this out to be a uber-efficient web host for thousands of people. This is targeted mainly towards those who simply need a private file host and BitTorrent client. Anything you don’t need, you can remove later.
Ubuntu can be downloaded from the official Ubuntu website. If the computer you’ll be using is a slower model, you might what to consider using the alternative text-mode installer available instead of the live CD on the site. What your are downloading is an ISO, an image of a CD. This image needs to be burned to a blank CD. Depending upon what operating system you’re using, you can either either a number of applications in Windows to get the job done ( CD Burner XP, ISO Recorder), or you can use a simple command in Linux (if the file is in your home directory) to do it:
cdrecord ubuntu-7.04-desktop-i386.iso

Burning a CD image in a console
Reboot your computer while the CD is in the drive. Select to install Ubuntu, and the setup process is extremely simple. You’ll be asked about what language you’ll want to use, and to setup a user account. The hardest part can be the partitioning, but if all you’ll be using this for is a BitTorrent box, you can just choose to use guided partitioning on to wipe the entire drive. Once the installation has finished, reboot and login using the newly configured user name and password. Now, you’re set to begin configuring the software.
Creating the “Headless” Server
Once the tutorial is finished, you should be able to disconnect the monitor from this computer, and never have to physically touch it again. If you need to configure anything, you’ll be able to do so via a console (SSH) or a remote desktop (VNC). You can leave the monitor and its peripherals connected if you like if its easier, because you now have a fully functional computer with an awesome operating system. If you want to create a headless server, browse through the menus at the top to “Applications->Accessories->Terminal”. From there, type these commands in:
sudo apt-get install openssh-server tightvncserver
sudo update-rc.d gdm remove
Note: You can add the GUI to start again at boot with this command:
sudo update-rc.d gdm defaults
Using these steps, you are installing a few remote administrative packages, and removing the GUI from starting when the computer is turned on. Now record the computer’s IP address somewhere handy by entering the following command:
ifconfig eth0
You’ll want to copy down the address in the “inet addr” field. The next time you restart your computer, you’ll be able to login that IP using SSH with your user name and password. You can use the regular SSH client built into Linux, or use a popular client like Putty if you have a different operating system.
If you’d like to use a graphical interface, there a several clients you can use to connect to the VNC session, such as RealVNC. Once you’ve logged in via SSH, you can always start a remote desktop session (if needed) using VNC:
vncserver -geometry 800×600
And kill it using:
vncserver -kill :1
Depending on how you want to work on the server is your choice. First, you can use SSH to connect via a console to enter commands. Secondly, if you want to configure it using a remote desktop, you can use VNC. Or, you can still use the computer as a regular desktop and finish the configuration locally. All of the steps from now on can be done one of those three ways. Note, when we need to configure Azureus, you will have to use a graphical interface to do so. Now you’re set to configure the software needed to build the BitTorrent box.
Configuring the External Hard Drive (Optional)
After the installation is done, you can optionally add an external hard drive to make it easier to move your data. We’ll be using a service called “ autofs” to automatically detect your hard drive and make it ready to share on the network each time you plug it in. To install autofs, use this command:
sudo apt-get install autofs
Once that finishes, you’ll want to connect your external hard drive and find out what device Ubuntu assigns it. After plugging in the hard drive wait a few seconds and then enter this command:
dmesg | tail
You should see something very similar to this:
[47820.164000] sdb: Write Protect is off
[47820.164000] sdb: Mode Sense: 03 00 00 00
[47820.164000] sdb: assuming drive cache: write through
[47820.164000] SCSI device sdb: 398297088 512-byte hdwr sectors (203928 MB)
[47820.168000] sdb: Write Protect is off
[47820.168000] sdb: Mode Sense: 03 00 00 00
[47820.168000] sdb: assuming drive cache: write through
[47820.168000] sdb: sdb1
[47820.184000] sd 4:0:0:0: Attached scsi disk sdb
[47820.184000] sd 4:0:0:0: Attached scsi generic sg2 type 0
The line “[47820.168000] sdb: sdb1” is what you’ll want to pay attention to. This tells us that Ubuntu is assigning the device to “sdb”, and it’s partition is labeled as “sdb1″. “1″ being the first and only partition on the disk. Next, we’ll what to find out what kind of partition is on the disk. Enter this into the console:
sudo fdisk -l /dev/sdb
The “System” column will display what kind of partition it is. Take note on what type of partition it is for the following instructions. If it’s “HPFS/NTFS”, you’ll want to use the “ntfs-3g” driver. If it contains “FAT”, you’ll use the “vfat” driver. Finally, if it’s “Linux”, you can just use the “auto” driver. Note, if it is a NTFS partition, you will have to manually install the new NTFS read/write drivers by using:
sudo apt-get install ntfs-3g
Next, we’ll want to add this information to the autofs service. Use to following command to edit to autofs master configuration file:
sudo nano /etc/auto.master
Note: You can replace “nano” with your preferred text editor. To save a file in nano, use the keyboard shortcut Ctrl+O. To exit, press Ctrl+X.
Now, find the line containing:
#/misc /etc/auto.misc
Change it to:
/misc /etc/auto.misc –timeout=60
Save it and edit the autofs “miscellaneous” configuration file next by entering this command:
sudo nano /etc/auto.misc
Add this to the bottom of the file:
external -fstype=ntfs-3g :/dev/sdb1
Remember to replace “ntfs-3g” with the type of driver you found earlier in this section. Note, if you are using “ntfs-3g”, you might want to append “,force” , making it “-fstype=ntfs-3g,force”. This makes it easier to use uncleanly unmounted drives. This maybe a little risky, but it makes it so much easier to troubleshoot.
Finally, restart the autofs service:
sudo /etc/init.d/autofs restart
Now, every time anything tries to find files in the “/misc/external” directory, Ubuntu will attempt to automatically mount that drive to be used.
The BitTorrent Client
Installation
Now for the heart of your BitTorrent box. We’ll be using the Azureus BitTorrent client because it has a huge plug-in base, and we can configure it to run in a silent service mode without needing the GUI. The first thing you’ll want to do is to download the Azureus client and find a simple place to keep it in. You’ll need to install the Azureus dependencies, download the client, and retrieve the plugins. Enter the following commands to do so:
sudo apt-get install sun-java5-jre libswt3.2-gtk-java
mkdir ~/software
cd ~/software
mkdir azureus
cd azureus
wget \
http://prdownloads.sourceforge.net/azureus/Azureus2.5.0.4.jar?download \
-O Azureus2.jar
wget http://azureus.sourceforge.net/cvs/log4j.jar
wget http://azureus.sourceforge.net/cvs/commons-cli.jar
wget http://nerdica.com/wp-content/uploads/2007/06/azureus
wget http://nerdica.com/wp-content/uploads/2007/06/azureus-gui
mkdir ~/bin
mv azureus-gui ~/bin/
chmod +x ~/bin/azureus-gui
Log out and then log back in for the new program files in your ~/bin/ directory to be recognized. Then edit the service configuration file:
sudo nano ~/software/azureus/azureus
Replace “(your user name)” with your actual user name. Do the same (line 39, to be exact) with the azureus-gui launcher:
sudo nano ~/bin/azuereus-gui
Save it, and then move it to it proper location using this command:
sudo mv ./azureus /etc/init.d/azureus
Plug-in Configuration
Now we’ll want to open up Azureus to edit a few configuration options to get everything in place, and to install the web UI for remote administration. Enter this command to open Azureus:
azureus-gui
Follow the simple setup wizard until the application has reached the main window. Once the initial configuration is done, you can now close the program by browsing to “File->Exit”. Next we’ll install the HTML Web UI plug-in. While we’re at it, you can extend Azureus with a plethora of plug-ins at their website. Enter the following commands do download and install it:
wget http://azureus.sourceforge.net/plugins/azhtmlwebui_0.7.6.jar
mkdir ~/.azureus/plugins/azhtmlwebui
mv azhtmlwebui_0.7.6.jar ~/.azureus/plugins/azhtmlwebui/
You can now use and Internet Browser such as Firefox to browse straight to the HTML Web UI whenever the Azureus service is running to download torrents. You can do so by entering the IP address of the BitTorrent Box, followed by the port “6886″. For example:
http://127.0.0.1:6886/

The Azureus HTML Web UI
You can add new BitTorrents by browsing to the “Upload” tab, and you can monitor all of your BitTorrents by browsing to the “Downloads” tab. You can tweak a few bandwidth settings by clicking on “Options”. Enjoy your sleek, easy accessible Azureus Web UI.
Now, if you have an external hard drive configured, you can setup Azureus to to move all completed torrents to the external hard drive. That can be set by reopening the Azureus GUI (azureus-gui). Browse the menu to “Tools->Options”. Then, browse the left menu to “Files->Completion Moving”. Check the widget labeled “Move completed files (after download)” and change the directory to “/misc/external”. If you do not have an external hard drive to use, just leaves all those options as the default.

Tweaking the download settings
If you’d like, you can also configure a user name and password to use for the Web UI. Browse the left menu to “Plugins->HTML Web UI”. At the bottom of the configuration panel are options to set up a user name and password.
Save your configuration by clicking “Save” at the bottom of the panel and exiting Azureus.
Starting the Service at Boot
Now that everything is set, you’ll want to make sure Azureus start up with your computer boots. Do this by adding the service to the Ubuntu runlevels at boot and shutdown with the following commands:
sudo cp ~/software/azureus/azureus /etc/init.d/
sudo chmod +x /etc/init.d/azureus
sudo update-rc.d azureus defaults
Now, Azureus will start when the server is booting. If you what to manually stop and start the service, you can do so by entering:
/etc/init.d/azureus stop
/etc/init.d/azureus start
Note: Azureus is now running in a completely silent mode. You will not see the Azureus icon in the icon tray of Gnome when the computer boots. If you ever need to configure Azureus, make sure to stop the service and then open the GUI to do so.
You can also find out about more of this section of the tutorial by visiting the AzureusWiki (copyrighted under the GFDL) page about it.
Hamachi
Installation
Hamachi is a VPN software used to easily create small personal networks that will burn through just about any firewall. The Linux client is available on their website. You’ll want to set this up so it will be much easier to connect to the Samba share hosting all of your files. Installing Hamachi is about the same as configuring Azureus. You’ll have to download the software, and then configure it to run at boot. You’ll begin by download the software package and extracting it somewhere useful. Enter the following commands to do so:
cd ~/software
wget http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz
tar xvfz hamachi-0.9.9.9-20-lnx.tar.gz
wget http://nerdica.com/wp-content/uploads/2007/06/hamachi_service \
-O hamachi-0.9.9.9-20-lnx/
Next, install the software
cd hamachi-0.9.9.9-20-lnx
sudo make install
sudo ./tuncfg/tuncfg
Note: If you are using Ubuntu 7.10 (Gutsy Gibbon), you may have to enter the following commands, and retry the previous installation to get everything to work:
sudo apt-get install upx-ucl-beta
cd /usr/bin
sudo upx -d hamachi
Then you’ll want to add a new Hamachi service to the server. First, you need to start by adding a new driver to be loaded when the computer starts. Edit Ubuntu’s modules configuration file to do so:
sudo nano /etc/modules
Append “tun” to the end of the file. Hamachi uses the “tun” module to be able to create a fake network device.
Now, we’ll add the new Hamachi service configuration. Download the Hamachi service configuration file and add it to the the proper runlevel as follows:
sudo cp ~/software/hamachi_service /etc/init.d/
sudo chmod +x /etc/init.d/hamachi_service
sudo update-rc.d hamachi_service defaults
Configuration
Next, you’ll want to create and join a network to join. First, you’ll start be creating a Hamachi account to use. Enter the following commands to create and account, and to go online:
hamachi-init
hamachi start
hamachi login
hamachi set-nick MyUserName
Make sure you replace “MyUserName” with a nick you would like to be identified by. Then, create a network to share you data with these few Hamachi commands, while replacing MyNetwork and MyPassword with your personal new network preferences:
hamachi create MyNetwork MyPassword
hamachi go-online MyNetwork
Now you have Hamachi completely set up for private LAN use. After you reboot, Hamachi will start automatically and connect to your network. If you ever want to reconfigure Hamachi for new networks, do so as root:
sudo hamachi join NewNetwork NewPassword
The last thing you’ll need to do is record your Hamachi IP for safe-keeping. You can do so by entering the following into a terminal:
ifconfig ham0
Copy down the address listed in the “inet addr” field.
Samba
Now, to finally be able to download your BitTorrents and to share them across your personal network. We’ll be using Samba, a implementation of the Windows SMB service for Linux. Samba allows you to not only copy files, but to stream them on the fly.
Installation
To begin, enter the following command to install the Samba package.
sudo apt-get install samba smbfs
Next, you’ll need to create a user account to access the Samba share. Do so by adding the user name to the Samba user list:
sudo smbpasswd -a (your user name)
Replace “(your user name)” with your personal user name. Enter in your password twice when it asks.
Next, you’ll have to edit the Samba configuration file. Do so by entering the following:
sudo nano /etc/samba/smb.conf
Find the line with:
; security = user
And uncomment it by removing the semicolon like so:
security = user
Now you’ll want to add an entry to share the directory where all of your downloaded BitTorrents have moved to. You can do so by appending an entry like so at the bottom of the “smb.conf” file:
[Downloads]
comment = Contains Azureus Downloads
path = /misc/external
browseable = yes
valid users = (your user name)
writable = yes
If you did not configure the external hard drive, the default directory Azureus hold transfers is in the “/home/(your user name)/Azureus Downloads/” directory. Remember to replace “(your user name)” with your personal user name. Also, you’ll have to leave the entire directory in quotes, because it contains a space. Replace “/misc/external” with that if needed. Now to test the Samba configuration file and to restart the Sambe service by entering the following:
sudo testparm
sudo /etc/init.d/samba restart
Once all parts of this tutorial are complete, you should be able to browse to the Hamachi IP (“http://5.x.x.x:6886″) address of the BitTorrent box to send and queue BitTorrent files. Use your file manager, you can browse to the Samba share to pick them up later. In Ubuntu you can browse your downloads by going to “Places->Connect to Server”. Once the dialog box pops up, change the server type to “Windows share”, and enter in the login information for your server. In Windows, you can open Windows Explorer, type the address of your server into the URL bar (“\\5.x.x.x”), and browse your files.

Browsing downloaded files shared with Samba via Hamachi
In Conclusion
After completing this tutorial, you now have a fully functioning BitTorrent box configured to share its downloads across a secure, private network. You can even copy your downloaded files straight off the USB external hard drive, if you have one. Once you have a Hamachi client configured on you personal desktop or laptop, you can connect to the BitTorrent box no matter where you are. There are many things you can do after this point. You can use it to share music, movies, and other personal data. You can use port forwarding on a router to give open access to your BitTorrent box across the Internet. With these simple tools, you are now able to download and share data however you like.
Discuss this the forums.
[EDIT 7/1/07 - 1:03 PM] Added a new screenshot and a few captions. Fixed a few spelling errors.
[EDIT 7/4/07 - 4:29 PM] Fixed a few syntax errors.
[EDIT 11/21/07 - 2:42 PM] Added 7.10 Hamachi fix.