lev neiman dot com

29Jul/11

Create your own personal IM “cloud”!

Recently I have gotten around to purchasing my own VPS - Virtual Private Server. I did it because I wanted to have a server with root access on a pretty fast and reliable connection that I could use remotely from everywhere. One of the more useful things I have found to do on it is to run a chat client that I can use remotely from either web interface or SSH. What follows below is a high level description and instructions on how to setup your own IM "cloud"!

Why do this?

I have been using Instant Messaging (IM) ever since I have started using internet itself. Overtime I have accumulated several different account names on several different services (such as gtalk, AOL IM, yahoo, facebook chat, etc.) I also have found myself using more and more devices to access my IM services, such as different desktops/laptops and smart phones. Popular IM services are supported on nearly all platforms, so it is relatively easy to move from one device to the next, however there are problems associated with this:

  • Must setup each client on different platform at least once.
  • Problems with signing on to multiple accounts at same time.
  • Your screen name is signed on only while you are running the client.
  • Logs of your chats (if you like to log) go into many different places.
  • It is relatively hard to script most IM clients.

Through services like Meebo it is possible to move to a single client that you access from a webfront. However it gives Meebo access to all of your logs, and you still cannot script it very well. Wouldn't it be nice if you could set up something akin to Meebo but you had total control over it? It sure is nice, however it will require some technical knowledge (mostly getting around linux stuff) and a bit of monetary investment, but in the end it is a lot more convenient, secure and fun than using Meebo or setting up IM client separately on each platform you use.

Setting up your server

First you need to have access to a server for which you have root access. One way is to dedicate one of your physical computers at home for the task and leave it on 24/7 on a relatively good internet connection. Through a service like DDNS you can get a unique domain name that will resolve to your machine's IP address.

Another way is to buy a VPS (Virtual Private Server). You can safely start with the cheapest one you can buy as you will not need a lot of bandwidth. I got mine from JTL Networks for $20/month. The plus for VPS is that it will likely have a far superior uptime than a home server, and it's running cost will not add up to your electricity bill.

Now we need to decide on a choice of operating system. I recommend something that has APT since it makes installing most of the programs you will need relatively easy. I used Ubuntu 10.04, however Debian is also a good and possibly even better choice.

Required software

Once you have the server up and running you can start installing these core programs on it. For most of these the command to install should simply be "sudo apt-get install ".

Required software Description
SSH host You will need this to login to your server.
irssi IRC command line client. This in conjunction with bitlbee will be your chat client that will run 24/7 on the server. If you choose to log your conversations, they will all be under ~/irclogs. It is not too hard to learn how to use it from command line, and it allows relatively easy time scripting with Perl. Also it has IRC proxy feature which is very useful for using a client like Pidgin to connect to your remote server for chatting (more details about this described later).
bitlbee Bitlbee is a chat client that uses libpurple (same library that Pidgin uses) to connect to various screen name accounts on various chat protocols. It then sets up an IRC server that irssi can connect to. I run both of these on same machine.

After you install these programs you will need to configure them. If you go to their respective homepages you can find many useful links on how to do this. However one tip useful for configuring irssi is to sometimes directly edit its config file that can be found in ~/.irssi/config. Similar thing can be done for bitlbee, however it's config file can be a bit hard to find and you would need to be root or change permissions on the file to even view it. It is located in /var/lib/bitlbee/.

Creating a web interface and using local chat clients

If you wish to create a web interface then you will also need to install and configure these additional programs:

Web UI programs Description
Apache webserver If you would like a web based interface you will need apache or some other webserver. Without it you could only interact with irssi through SSH or after setting up it's IRC proxy.
Shellinabox This allows you to login into your server using a web interface. The last time I tried, I couldn't get it to use SSL by itself, so if you want actual security, you will need to set up SSL for Apache - http://www.tc.umn.edu/~brams006/selfsign_ubuntu.html, and then setup a reverse proxy in Apache to go to the port Shellinabox is listening on. To do so add following to /etc/apache2/apache2.conf file and then restart apache (this is assuming shellinabox is running on port 4200):

<Location /shell>
ProxyPass http://localhost:4200/
Order allow,deny
Allow from all
SSLCipherSuite HIGH:MEDIUM
</Location>
CGIIRC Gives a pretty nice webbased IRC connection. You could also use something like Mibbit but that will circumvent privacy as Mibbit will be able to see your chat traffic.

Now you are still forced to use irssi and its command line interface to chat. But a lot of times it is nice to use an actual GUI which is easier to use as well as has features like notification popups. To do this we will need to setup an IRC proxy to bitlbee server from irssi. This is actually pretty easy, just read this page - http://www.irssi.org/documentation/proxy.

The only downside to irssi proxies is that they are not encrypted which means that someone could very easily be eavesdropping on you. This is easy to overcome by tunneling connection to irssi proxy through SSH. All you do is execute a one line command in shell on local machine:

ssh -f username@remote_host -L <local_port>:localhost:<remote_port> -N

Now in your local IRC client like Pidgin or something else you can connect to localhost:local_port and that will then connect you to your remote bitlbee server! All traffic will now be encrypted via SSH, so you can rest easy.