Friday, January 29, 2010

Setup a Subversion Server in 4 Minutes

1. Create a Repository

svnadmin create /svnrepos

2. Create a SVN User

vi /svnrepos/conf/svnserve.conf

In that file add these three lines:

anon-access = none<br />auth-access = write<br />password-db = passwd

Create a password file:

vi /svnrepos/conf/passwd

In that file add a line for your user:

# add users in the format : user = password<br />tony = mypassword

3. Import Your Project

(assuming you’ve put your project files in /projects/myrailsproject)

svn import /projects/myrailsproject file:///svnrepos/myrailsproject

4. Start the SVN Server as Daemon

svnserve -d

Done! You should now have a svn server running with one project named myrailsproject.

Try checking it out of the repository:

svn co svn://192.168.0.2/svnrepos/myyrailsproject

Since we set anon-access to none you should be prompted for username and password which you created in the file /svnrepos/conf/passwd.

Ejabber Installation using Apache

This tutorial is based on the original JWChat README files and it will guide you through the installation of the web-based Jabber client JWChat 1.0 beta 2 using a pre-generated package.

At the end, you will have JWChat running using ejabberd's internal HTTP Polling support. In case you, however, want to use the external component JabberHTTPBind instead, you should take a look at The odyssey of JWChat by Sabine Dinis Blochberger.

Please post a comment to this tutorial to suggest something, to report errors, or to report system and web server specific instructions. Naturally, you also can add a comment if you have questions. Further, you can ask JWChat specific questions in the chatroom jwchat@conference.jwchat.org.

  1. Configure ejabberd

    Make sure you have options similar to those on your ejabberd.cfg:

    {host, "jabber.mycompany.com"}.

    {listen,
    ...
    {5280, ejabberd_http, [http_poll]}

    With these options the URL for HTTP-Poll in your server will be:

    http://jabber.mycompany.com:5280/http-poll/
  2. Download JWChat

    Download a pre-generated package of JWChat and unpack it.

  3. Configure JWChat

    Edit config.js to suit your needs. You must at least set this option:

    var SITENAME = "jabber.mycompany.com"
  4. Copy to www

    Now you can copy the JWChat directory to its final destination. On Linux it could be /var/www/jwchat/

  5. Setup webserver

    Now you have to setup your web server so that it redirects requests from the URL given at HTTPBASE of config.js to an HTTP-Polling capable Jabber server component. Those instructions are for Apache 2.

    • .htaccess

      The easiest way to make redirection is creating a .htaccess file in the JWChat directory with this content:

      AddDefaultCharset UTF-8
      Options +MultiViews

      RewriteEngine On
      RewriteRule http-poll/ http://jabber.mycompany.com:5280/http-poll/ [P]
      In your Apache configuration file (/etc/apache2/apache2.conf) you must enable .htaccess files and proxy options:

      AllowOverride All

      Finally, enable rewrite and proxy modules for Apache:

      cd /etc/apache2
      ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
      ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/
      ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/
    • virtual host

      undocumented

    Restart your web server so changes take effect:

    apache2ctl restart

    And now you can open your browser in the URL (maybe similar to http://www.mycompany.com/jwchat/).

Transfer files securely with SFTP

File Transfer Protocol (FTP) was once the most widely used protocol for transferring files between computers. However, because FTP sends authentication information and file contents over the wire unencrypted, it's not a secure way to communicate. Secure Copy (SCP) and the more robust SSH File Transfer Protocol (SFTP) address this security concern by providing data transfer over a fully encrypted channel. You can use these alternatives for transferring files securely over the Internet or any other untrusted network.

Both SCP and SFTP rely on Secure Shell (SSH) as their underlying protocol. SSH establishes a secure and encrypted channel of communication between computers using authentication and encryption based on Public Key Infrastructure. SSH uses encryption for the authentication data exchanged to set up the session and the subsequent data transfer.

SSH server and client software ships with most modern operating systems. Clients for SCP and SFTP are available as part of the OpenSSH suite on most Linux systems. Apart from SCP and SFTP, SSH functions as a suitable platform for setting up remote shell and remote GUI desktop connections, tunneling between computers, setting up a SOCKS proxy for secure browsing, and port forwarding.

SCP and SFTP

SCP is a descendant of Remote Copy (RCP). Unlike in FTP, with SCP you can specify that the modification times, access times, and modes from the original file should be preserved. Also, unlike RCP, SCP can prompt for passwords when needed. Apart from copying files between your computer and a remote host, SCP can also transfer files between two remote hosts.

SCP is a handy command-line tool for batch processing. However, SCP works over SSH1, an older, deprecated version of SSH, so you're better off using alternatives like SFTP that work over SSH2.

SFTP is a full-fledged file transfer protocol that implements all the operations found in FTP, including ones SCP doesn't handle, such as renaming and deleting remote files.

SFTP runs as an SSH subsystem and works on standard SSH port 22 by default. It alleviates the need to open multiple additional ports on the firewall as in the case of FTP, where ports 20 and 21 need to be opened up for control and data traffic. An SFTP client called sftp is available in OpenSSH suite that ships with most Linux systems.

When using password-based authentication (you can avoid the need to supply passwords if the remote host allows password-less SSH authentication), this is how you would start an SFTP session:

sftp david@192.168.1.1

sftp prompts for a password, and on successful authentication, presents a shell with an sftp> prompt. Once in the sftp shell, you can run commands similar to those available on FTP, such as cd, lcd, ls, chmod, chgrp, get, put, rename, and rmdir. You can end the session by typing exit at the prompt.

SFTP servers

The OpenSSH suite is the most popular open source implementation of SSH. Its server is called sshd. You need sshd running on the server to listen on the SSH port and accept incoming connections. To enable or disable SFTP, you can edit the main sshd configuration file, which is at /etc/ssh/sshd_config by default. SFTP is enabled by default; you can comment out the following line to disable it:

Subsystem sftp /usr/libexec/openssh/sftp-server

You can restrict access to SCP and SFTP, along with rest of SSH functionality, based on the IP address of the connecting host by editing hosts.deny file to include a line like this:

sshd: 192.168.1.1

To block an entire network, you can specify the network and subnet address:

sshd: 192.168.1.0/24

or

sshd: 192.168.1.0/255.255.255.0

SFTP servers can cater clients running on any operating system. Some of the popular SFTP clients on Windows are FileZilla, WinSCP, and DataFreeway.

GUI clients for SFTP

In addition to command-line clients from the OpenSSH suite, the file browsers in popular desktop environments like GNOME and KDE have SFTP client capabilities. In Nautilus on GNOME or Konqueror on KDE, you can type the following in the location field:

sftp://david@192.168.1.1:/home/david

The file browser prompts for your password, and on successful authentication lists the files from the remote server in the file browser. You can drag and drop these files to copy them, and also right-click on files to change properties like name and permissions. You can double-click on files to open them in a suitable editor or viewer. You can also bookmark any SFTP-based directory so that you can quickly access it next time.