PART 1:
Subsy's Seedbox Setup Guide
Changelog:
- April 3rd 2010: Original version
- April 4th 2010: Minor Bugfixes
- April 5th 2010: Added FTP setup instructions
- April 13th 2010: Added multiple user setup instructions (optional)
- April 17th 2010: Fixed bug in Pure-FTPd setup instructions
- December 18th 2012: Updated for Ubuntu Server 12.04 (Tested using x64 version), and to use libtorrent 0.13.3 and rtorrent 0.9.3
Introduction
This guide will walk you through a full install of a secure seedbox environment, running rtorrent with the rutorrent web front end and the pureftpd FTP server.
The guide also includes optional steps to configure for multiple users, each with their own web login and running instance of rtorrent.
Pre-requisites: An Ubuntu 12.04 or later server (should also work on some earlier versions, and on other Debian based distros, but this is untested) with root SSH access.
Basics
Initial login
Login to your server as root via SSH
Code:
ssh root@<server IP>
(You can also use an SSH client if you prefer, eg PuTTY on Windows)
Type the password as requested
Create a new user that we’ll install everything with
For security purposes, we’re going to add a new user and disable SSH access for the root user
Code:
adduser <username>
Replace <username> with a username of your choosing.
Fill in all the details when prompted (e.g. password)
Add your new user to the sudoers file. This allows this user to use elevated privileges when needed to do things that normally only the root user could do.
Code:
visudo
In recent versions of Ubuntu this opens the sudoers file for editing in a lightweight editor called nano.
Scroll down and find this line:
Quote
On the next line add:
Quote
Replace <username> with the username we created earlier.
Hit CTRL-O to save the file (and hit Enter to confirm when prompted), then hit CTRL-X to exit the editor.
Lock down SSH
Now we will change some SSH settings.
We're going to use a different port, and prevent root access via SSH
Code:
nano /etc/ssh/sshd_config
Change the following lines as below.
Use a high port of your choosing. I recommend a port over 20000
Quote
Then add these lines at the end of the file:
Quote
(As usual, replace <username> with the name of the user you created)
Hit CTRL-O to save the file (and hit Enter to confirm when prompted), then hit CTRL-X to exit the editor.
Now restart the SSH daemon
Code:
service ssh reload
Log out of SSH and log back in as the new user you created earlier
Code:
exit
ssh -p 21976 <username>@<server IP>
(Note the -p argument which specifies the new SSH port that you configured in the last step)
Type the password as requested
Update packages
Ok, now we're going to make sure our Ubuntu installation is up to date.
Code:
sudo apt-get update
This will update the package database with all the latest packages available. Using the sudo command will temporarily elevate your privileges to be able to execute these commands that normally only a super user could execute.
Code:
sudo apt-get upgrade
This will upgrade any packages that are out of date on your install.
Install necessary basic packages
Ok, now lets install some important packages that we're going to need throughout this guide:
Code:
sudo apt-get install apache2 apache2-utils autoconf build-essential ca-certificates comerr-dev libapache2-mod-php5 libcloog-ppl-dev libcppunit-dev libcurl3 libcurl4-openssl-dev libncurses5-dev ncurses-base ncurses-term libterm-readline-gnu-perl libsigc++-2.0-dev libssl-dev libtool libxml2-dev ntp openssl patch libperl-dev php5 php5-cli php5-dev php5-fpm php5-curl php5-geoip php5-mcrypt php5-xmlrpc pkg-config python-scgi dtach ssl-cert subversion unrar zlib1g-dev pkg-config unzip htop irssi curl cfv
Configure Apache
Basic configuration
We need to configure the Apache web server with some modules that we’ll need:
Code:
sudo a2enmod ssl
sudo a2enmod auth_digest
We want to edit our apache conf file to change some options.
Code:
sudo nano /etc/apache2/apache2.conf
Change the Timeout option to '30'
Quote
and add (or change if the line already exists)
Quote
Hit CTRL-O to save the file (and hit Enter to confirm when prompted), then hit CTRL-X to exit the editor.
Restart apache
Code:
sudo service apache2 restart
add a file named info.php that we will use to check that php is setup correctly
Code:
echo '<?php phpinfo(); ?>' | sudo tee /var/www/info.php
Lets just check apache is up and running
Open a browser and go to
Quote
You should see the phpinfo page. if not, you failed.
Configure Apache for HTTPS and password protection
We are going to create an SSL certificate so that we can access the server via https
Code:
sudo openssl req -new -x509 -days 365 -nodes -newkey rsa:2048 -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem
chmod 600 /etc/apache2/apache.pem
This will create a self-signed certificate for your server that lasts for 1 year. You'll be prompted for some information for the cert. Whenever you're asked for a name, use your domain name if you have one. The rest you can leave blank or fill in with whatever you like.
Now lets add password protection
Code:
sudo htdigest -c /etc/apache2/htpasswd rutorrent <username>
Where <username> is the username you'll use to connect to the rutorrent web UI. Preferably different than your system user for obvious reasons.
After running this command, you'll be prompted for a password. This will be the password you enter to log into the rutorrent web UI.
Code:
sudo nano /etc/apache2/sites-available/default
Now copy the following and paste to replace the contents of the file we're editing.
Then replace both instances of <servername or IP> with your real servername or IP address
Quote
Now lets configure apache for HTTPS
Code:
sudo a2ensite default-ssl
We now need to modify the apache ports configuration file
Code:
sudo nano /etc/apache2/ports.conf
Replace the contents of that file with the text below
Quote
And now lets put these changes into effect
Code:
sudo /etc/init.d/apache2 restart
Check that everything is working by opening a browser and going to:
Quote
You should see this message:
Quote
Subsy's Seedbox Setup Guide
Changelog:
- April 3rd 2010: Original version
- April 4th 2010: Minor Bugfixes
- April 5th 2010: Added FTP setup instructions
- April 13th 2010: Added multiple user setup instructions (optional)
- April 17th 2010: Fixed bug in Pure-FTPd setup instructions
- December 18th 2012: Updated for Ubuntu Server 12.04 (Tested using x64 version), and to use libtorrent 0.13.3 and rtorrent 0.9.3
Introduction
This guide will walk you through a full install of a secure seedbox environment, running rtorrent with the rutorrent web front end and the pureftpd FTP server.
The guide also includes optional steps to configure for multiple users, each with their own web login and running instance of rtorrent.
Pre-requisites: An Ubuntu 12.04 or later server (should also work on some earlier versions, and on other Debian based distros, but this is untested) with root SSH access.
Basics
Initial login
Login to your server as root via SSH
Code:
ssh root@<server IP>
(You can also use an SSH client if you prefer, eg PuTTY on Windows)
Type the password as requested
Create a new user that we’ll install everything with
For security purposes, we’re going to add a new user and disable SSH access for the root user
Code:
adduser <username>
Replace <username> with a username of your choosing.
Fill in all the details when prompted (e.g. password)
Add your new user to the sudoers file. This allows this user to use elevated privileges when needed to do things that normally only the root user could do.
Code:
visudo
In recent versions of Ubuntu this opens the sudoers file for editing in a lightweight editor called nano.
Scroll down and find this line:
Quote
root ALL=(ALL) ALL
On the next line add:
Quote
<username> ALL=(ALL) ALL
Replace <username> with the username we created earlier.
Hit CTRL-O to save the file (and hit Enter to confirm when prompted), then hit CTRL-X to exit the editor.
Lock down SSH
Now we will change some SSH settings.
We're going to use a different port, and prevent root access via SSH
Code:
nano /etc/ssh/sshd_config
Change the following lines as below.
Use a high port of your choosing. I recommend a port over 20000
Quote
Port 21976
Protocol 2
PermitRootLogin no
X11Forwarding no
Protocol 2
PermitRootLogin no
X11Forwarding no
Then add these lines at the end of the file:
Quote
UseDNS no
AllowUsers <username>
AllowUsers <username>
(As usual, replace <username> with the name of the user you created)
Hit CTRL-O to save the file (and hit Enter to confirm when prompted), then hit CTRL-X to exit the editor.
Now restart the SSH daemon
Code:
service ssh reload
Log out of SSH and log back in as the new user you created earlier
Code:
exit
ssh -p 21976 <username>@<server IP>
(Note the -p argument which specifies the new SSH port that you configured in the last step)
Type the password as requested
Update packages
Ok, now we're going to make sure our Ubuntu installation is up to date.
Code:
sudo apt-get update
This will update the package database with all the latest packages available. Using the sudo command will temporarily elevate your privileges to be able to execute these commands that normally only a super user could execute.
Code:
sudo apt-get upgrade
This will upgrade any packages that are out of date on your install.
Install necessary basic packages
Ok, now lets install some important packages that we're going to need throughout this guide:
Code:
sudo apt-get install apache2 apache2-utils autoconf build-essential ca-certificates comerr-dev libapache2-mod-php5 libcloog-ppl-dev libcppunit-dev libcurl3 libcurl4-openssl-dev libncurses5-dev ncurses-base ncurses-term libterm-readline-gnu-perl libsigc++-2.0-dev libssl-dev libtool libxml2-dev ntp openssl patch libperl-dev php5 php5-cli php5-dev php5-fpm php5-curl php5-geoip php5-mcrypt php5-xmlrpc pkg-config python-scgi dtach ssl-cert subversion unrar zlib1g-dev pkg-config unzip htop irssi curl cfv
Configure Apache
Basic configuration
We need to configure the Apache web server with some modules that we’ll need:
Code:
sudo a2enmod ssl
sudo a2enmod auth_digest
We want to edit our apache conf file to change some options.
Code:
sudo nano /etc/apache2/apache2.conf
Change the Timeout option to '30'
Quote
Timeout 30
and add (or change if the line already exists)
Quote
ServerTokens Prod
Hit CTRL-O to save the file (and hit Enter to confirm when prompted), then hit CTRL-X to exit the editor.
Restart apache
Code:
sudo service apache2 restart
add a file named info.php that we will use to check that php is setup correctly
Code:
echo '<?php phpinfo(); ?>' | sudo tee /var/www/info.php
Lets just check apache is up and running
Open a browser and go to
Quote
http://<servername or IP>/info.php
You should see the phpinfo page. if not, you failed.
Configure Apache for HTTPS and password protection
We are going to create an SSL certificate so that we can access the server via https
Code:
sudo openssl req -new -x509 -days 365 -nodes -newkey rsa:2048 -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem
chmod 600 /etc/apache2/apache.pem
This will create a self-signed certificate for your server that lasts for 1 year. You'll be prompted for some information for the cert. Whenever you're asked for a name, use your domain name if you have one. The rest you can leave blank or fill in with whatever you like.
Now lets add password protection
Code:
sudo htdigest -c /etc/apache2/htpasswd rutorrent <username>
Where <username> is the username you'll use to connect to the rutorrent web UI. Preferably different than your system user for obvious reasons.
After running this command, you'll be prompted for a password. This will be the password you enter to log into the rutorrent web UI.
Code:
sudo nano /etc/apache2/sites-available/default
Now copy the following and paste to replace the contents of the file we're editing.
Then replace both instances of <servername or IP> with your real servername or IP address
Quote
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<Location /rutorrent>
AuthType Digest
AuthName "rutorrent"
AuthDigestDomain /var/www/rutorrent/ http://<servername or IP>/rutorrent
AuthDigestProvider file
AuthUserFile /etc/apache2/htpasswd
Require valid-user
SetEnv R_ENV "/var/www/rutorrent"
</Location>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<Location /rutorrent>
AuthType Digest
AuthName "rutorrent"
AuthDigestDomain /var/www/rutorrent/ http://<servername or IP>/rutorrent
AuthDigestProvider file
AuthUserFile /etc/apache2/htpasswd
Require valid-user
SetEnv R_ENV "/var/www/rutorrent"
</Location>
</VirtualHost>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<Location /rutorrent>
AuthType Digest
AuthName "rutorrent"
AuthDigestDomain /var/www/rutorrent/ http://<servername or IP>/rutorrent
AuthDigestProvider file
AuthUserFile /etc/apache2/htpasswd
Require valid-user
SetEnv R_ENV "/var/www/rutorrent"
</Location>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<Location /rutorrent>
AuthType Digest
AuthName "rutorrent"
AuthDigestDomain /var/www/rutorrent/ http://<servername or IP>/rutorrent
AuthDigestProvider file
AuthUserFile /etc/apache2/htpasswd
Require valid-user
SetEnv R_ENV "/var/www/rutorrent"
</Location>
</VirtualHost>
Now lets configure apache for HTTPS
Code:
sudo a2ensite default-ssl
We now need to modify the apache ports configuration file
Code:
sudo nano /etc/apache2/ports.conf
Replace the contents of that file with the text below
Quote
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
NameVirtualHost *:443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
NameVirtualHost *:443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
And now lets put these changes into effect
Code:
sudo /etc/init.d/apache2 restart
Check that everything is working by opening a browser and going to:
Quote
https://<servername or IP>
You should see this message:
Quote
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
This is the default web page for this server.
The web server software is running but no content has been added, yet.