If you have any feedback about better ways of doing the same, please let me know and I
will update the page accordingly.
ISPs typically provide two kinds of IP address plans for their customers: dynamic and static addresses. Most people use dynamic IP addresses because they are 2-3 times cheaper as compared to static IP addresses. This means that the IP address of your machine (or the external IP address of your router if you have one) is given to you only for a lease of time. Once this expires, a new IP address will be given. In this section, we will see how we can get a static hostname mapping for your machine inspite of having a dynamic IP address.
To get a static hostname, you will need to first create an account at http://www.dyndns.com. These accounts are free. Once logged in, update your account by providing information about your home machine and choosing a static hostname from the options provided.
Once your account is setup and configured, the next step is to setup your home router or machine to update your DynDNS account whenever you get a new IP address. Most routers available in the market already support this capability, so first check if your router does this. If it does, all you have to do is enter your DynDNS account information in your router's web interface and you are done. If it doesn't, you will have to use a third party software to provide the same functionality. You can find some such software here: (http://www.dyndns.com/support/clients).
I don't like the way the groups structure is setup by Ubuntu by default. So, I changed a bunch of things to suit my taste better.
|
$ sudo mkdir -m 775 /home/cvs /home/svn /home/http /home/http/cgi
$ sudo chmod g+s /home/cvs /home/svn /home/http /home/http/cgi $ sudo chgrp users /home/cvs /home/svn /home/http /home/http/cgi |
The default SSH configuration is quite safe to be used in a private environment. But, for a server which is exposed to the outside world, a few changes to the settings might be useful. Here are the changes I made:
|
$ sudo apt-get install ssh openssh-server
|
|
$ sudo vim -c "%s/PermitRootLogin yes/PermitRootLogin no/g" -c ":wq" /etc/ssh/sshd_config
|
|
$ sudo vim -c "%s/RSAAuthentication yes/RSAAuthentication no/g" -c ":wq" /etc/ssh/sshd_config
|
|
$ sudo vim -c "%s/\#PasswordAuthentication yes/PasswordAuthentication no/g" -c ":wq" /etc/ssh/sshd_config
|
|
$ sudo /etc/init.d/ssh restart
|
Installing the CVS server is the easiest of the lot. The following command should do it:
|
$ sudo cvs -d /home/cvs init
|
|
$ mkdir test && cd test && cvs -d /home/cvs import vendor release && cd .. && rm -rf test
$ cvs co [your_machine_name]:/home/cvs/test |
This section describes how to setup the SVN server. It allows access in one of two ways -- over SSH or using Apache.
|
$ sudo apt-get install libapache2-svn libneon26 libsvn1 subversion subversion-tools
|
|
$ sudo svnadmin create /home/svn
|
|
$ sudo bash -c "find /home/svn | xargs file | grep directory | cut -f1 -d':' | xargs chmod g+wx"
$ sudo bash -c "find /home/svn | xargs file | grep -v directory | cut -f1 -d':' | xargs chmod g+w" |
|
$ svn co svn+ssh://[your_machine_name]/home/svn
|
I used apache2 as the HTTP server. Here are the steps I followed:
|
$ sudo apt-get install apache2 apache2-mpm-worker
apache2-utils apache2.2-common libapr1 libaprutil1
libpcre3 libpq5
|
|
$ sudo bash -c "echo ServerName \"XXXXXX\" >> /etc/apache2/apache2.conf"
|
|
$ sudo rm -rf /var/www |
|
$ sudo /etc/init.d/apache2 restart
|
|
$ wget http://www.google.com -O /home/http/test-index.html
$ firefox http://[your_domain_name]/test-index.html |
Enable SSL request handling for the server.
|
$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl
$ sudo ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/ssl |
|
$ sudo mkdir ssl
$ sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf ssl/apache.pem |
|
$ sudo bash -c "echo Listen 443 >> /etc/apache2/ports.conf"
|
|
$ sudo /etc/init.d/apache2 restart
|
|
$ wget http://www.google.com -O /home/http/test-index.html
$ firefox https://[your_domain_name]/test-index.html |
Using SSH to access your SVN server requires all SVN users to have login accounts on your home machine. You might or might not want this. Further, maintaining SSH keys for everyone can be a big headache. Luckily, SVN also provides an alternative approach for accessing it, using Apache2 Webdav. The advantage of this method is that you don't necessarily have to give all users who want to use the SVN an account on your machine. Apache maintains a separate user account system, that you can use.
|
$ sudo htpasswd -c -m /home/svn/conf/dav_svn.passwd USER_TO_ADD
|
|
<Location /svn>
DAV svn SVNPath /home/svn AuthType Basic AuthName "SVN Repository" AuthUserFile /home/svn/conf/dav_svn.passwd Require valid-user AuthzSVNAccessFile /home/svn/conf/authz </Location> |
|
$ sudo /etc/init.d/apache2 restart
|
|
$ svn co https://[your_domain_name]/svn
|
Typically SVN account passwords have to managed by the system administrator. This is inconvenient and not safe in general. Since SVN does not provide direct capability to allow users to modify their own passwords, here is a simple hack to do this. We first enable execution of CGI scripts for Apache. This can be a security risk, so we try to keep the permissions as restricted as possible.
|
$ sudo vim -c "%s/#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi .pl/g" -c ":wq" /etc/apache2/apache2.conf
|
|
<Directory /home/http/cgi/*>
AuthType Basic AuthName "SVN Repository" AuthUserFile /home/svn/conf/dav_svn.passwd Require valid-user Options ExecCGI -MultiViews +SymLinksIfOwnerMatch AllowOverride None </Directory> |
| $ sudo wget
http://www.kluge.net/~felicity/random/htpasswd-pl.txt -O
/home/http/cgi/htpasswd.pl $ sudo chmod +x /home/http/cgi/htpasswd.pl |
|
$ sudo bash -c "echo www-data ALL=NOPASSWD: ALL >> /etc/sudoers"
|
You are all set. Have fun! Please do let me know your
experiences, comments and suggestions. Especially, if I missed
any setting or if there is a better way of doing the same,
please let me know.