Configuring a Free Always On IRC Client
Internet Relay Chat (IRC) has been around for a long time now. It’s a protocol for group chat on a client/server network model. What’s important is that it’s the de facto standard for communication among the Grey Hat Group, the cybersecurity interest group I’m in at school.
In my Army days, I actually spent a large portion of my deployment on IRC. I communicated with different units and coordinated missions using mIRC, a proprietary Windows-only client. mIRC is responsible for creating the infamous “trout slap.” At home I was using XChat for a while. It’s cross-platform, it’s (kinda) free, and it was bundled with at least one of my Ubuntu installs. It worked well enough, but it’s become abandonware over the past few years. I then moved to HexChat, a truly free and actively maintained fork of XChat.
All of these clients are functional. I can connect to a server, join a channel with any of the above, and start chatting without a hiccup with any one of them. The problem arises when I invariably shutdown my laptop or it loses network connectivity. We use IRC because we want to be able to talk to each other in real time, and I don’t want to miss a thing. If my IRC client goes offline, then I miss out on the conversation. I also lose operator status on the channels I help maintain. (We don’t have services, not my fault.)
Nowadays I’ve moved my IRC client to a remote server from Amazon Web Services. AWS is a collection of remote computing resources. Since my server is always running, my client is always running. I just connect to the server from wherever I am to jump back into chat. I’m going to run through how to get a free EC2 instance, install a good IRC client, and access it remotely.
Getting a Free Server
To get started, you’re going to need an AWS account. Load up the front page and click the big Create a Free Account button. You can use an existing Amazon account, or create a new one. Keep clicking through and filling out forms. You need to provide your billing information, but I assure you that your first year will be free.
Click on the Launch Management Console button and log in with your brand new AWS credentials. Your account may take a moment to configure, so if you are having trouble logging in just wait for a few minutes.
AWS offers a lot of services, but the one we care about is called Elastic Compute Cloud (EC2) which provides scalable virtual machines for serving your stuff. Click on the EC2 link in the upper left. This will bring up the EC2 Management Console.
Check Free tier only on the left. Then find the Ubuntu Server 14.04 LTS (PV), SSD Volume Type option. In the future, versions and options may change. In that case, choose whichever Ubuntu option includes LTS and PV. Choose the 64-bit option if given a choice and click Select.
Ensure that a Micro instance is selected and that the selected option shows a Free tier eligible tag. Click Review and Launch.
Amazon will scold you for not limiting the IP addresses that can access your server. Ignore this. We will establish our own security once we get it running. Now you get to click Launch.
Now we are going to create a key pair to get access to our machine. Give your key pair a name and click Download Key Pair. Once you have downloaded your key, go ahead and click Launch Instances. On the next page, click View Instances to jump back to the EC2 Management Console.
This page will show you all the information about your new instance. Click Connect for a walkthrough of how to log in to your new server.
Now we’re going to connect to the instance with Secure Shell (ssh). I’ll explain logging in with Linux and OS X first, then with Windows.
Connecting to Your Server
Using Linux (or OS X)
Open up a terminal emulator and enter in the following command. Replace
example.pem with your key and
18.104.22.168 with your IP address.
$ ssh -i example.pem firstname.lastname@example.org
yes when prompted. If you get a permissions error run the following command substituting your key’s name. Then try again.
$ chmod 400 example.pem
Now you’re logged in! You can tell because your prompt will have changed to something like
ubuntu@ip-54-69-189-249:~$. Next we’ll set up our own key. Skip this if you already have ssh keys set up. Open another terminal window and enter the following command. Make sure you’re doing this in a new terminal window; we want to run this locally.
$ ssh-keygen -t rsa
Enter a good, memorable password. When finished, your key fingerprint will be displayed. Enter to following command to view your public key.
$ cat id_rsa.pub
Copy the whole thing and switch back to your other terminal window. On your server enter the following command to authorize your key on the server.
$ vim .ssh/authorized_keys
Press the I to enter insert mode and arrow to the end of the file. Paste (shift-control-V) your key onto a new line. Press escape to exit insert mode, type
:wq for write and quit, and hit enter. Now that your key is authorized on the server, you can connect with the following command substituting your server’s IP address.
On a Windows system, we’ll need PuTTY and PuTTYgen. The easiest way to install is by selecting A Windows installer for everything except PuTTYtel from the download page. Once installed, open PuTTYgen. In the Parameters section, select SSH-2 RSA for the Type of key to generate.
Click Load to open the key we downloaded.
From the drop down menu, change the selection from PuTTY Private Key File (*.ppk) to All Files (*.*).
Navigate to and select your key and click Open. Click OK in the dialog box.
Click Save private key. Click Yes to dismiss the password warning.
Be sure to save this key with the same file name (exluding the file extension). Now your key is formatted for use with PuTTY.
To connect open PuTTY. Select Session from the Category pane on the left and enter the following values.
- Host Name: email@example.com (substituting your server’s IP address)
- Port: 22
- Connection Type: SSH
Select Connection > SSH > Auth from the Category pane on the left. Select Browse…, select the converted (.ppk) key file, and click Open.
Select Session from the Category pane on the left. Enter a name for these settings in Saved Sessions and click Save. From now on, you can just load these settings instead of setting them all manually.
Click Open then Yes in the dialog box to connect.
Installing Your Software
Now that we know how to connect to our server, we need to configure it. The first thing to do is ensure that all the software on it is up to date. Run the following command to check for updates.
$ sudo apt-get update
Next run the following command to download and install the updates. Enter
y when prompted. This may take a couple minutes.
$ sudo apt-get upgrade
$ sudo apt-get install irssi screen
Screen is a very powerful utility that multiplexes virtual consoles. It does way more than we’re using it for here. We’re using so that even though we are starting a new log in session every time we log in to our server, we can keep the same IRC session. Enter the following command to create a new Screen session called
$ screen -S irc
Your screen will clear, but otherwise it won’t be obvious that you’ve entered Screen. This is a link to a good reference of Screen commands. Enter the command below to start up Irssi in the Screen session.
Since Irssi is a command-line client, there is a bit of a learning curve to get comfortable. To get started use
/connect <server> to log on to a server,
/join <channel> to join a channel, and
/nick <name> to set your username. Use alt-← and alt-→ to scroll through different windows. Check out the documentation to learn more.
When you’re done poking around on IRC, press control-A followed D to exit Screen. To close your ssh connection press control-D. Or you could just close the terminal. Screen will keep Irssi running for when you log back in. To get back on, reconnect to your server with ssh and enter to following command.
$ screen -r irc
Now you can get on and jump into channel whenever without missing anything. There is a bunch more you can learn or play with. Check out these resources to dig deeper.
- IRChelp.org – A pretty comprehensive guide to all things IRC
- Irssi Themes – The default Irssi interface isn’t the prettiest (I recommend xchat)
- Irssi Scripts – A list of scripts to extend Irssi’s interface (I recommend nicklist and screen_away)
- A Guide to Efficiently Using Irssi and Screen – A thorough explanation of using Irssi with Screen
- Screen Quick Reference – A quick… reference… for Screen
- IrssiNotifier – Get private message and highlight notifications on Android
- AWS Billing Alarm – Get notified when your free year ends (and maybe create a new account)