I've blogged on and on about Irssi, the single best IRC client out there, as most of you would agree. The reason it is so great, is the sheer number of features it has. There is no other client like it. In fact, here is a quick and dirty Top 10, why Irssi is so great:
- Perl scripting
- Slim, yet powerful
- Multi-server support
- Sensible defaults
- Tab completion
- /lastlog (need I say more?)
- Self-defined tab completion
- Paste detection
- Configurable keybindings
- Themes and formats
- Irssi proxy
Ok. So, a few more than 10. I could go on and on about the wonderful features that Irssi brings to the table. However, it's the last feature I mentioned, that I want to spend some time on: Irssi proxy.
When I use Irssi, as do most users, I use it inside of screen. I do this for a couple reasons. First, I want to be able to maintain my connection, without thinking about it. I hate having all these applications, just to do one thing here, and another thing there. I'm always in the terminal, so it makes sense to me to run a terminal-based IRC client. Second, I want to maintain my connection, so I always have access to backlogs, and I am always available for others to reach me. Thirdly, I want to be able to access my IRC connection, regardless of my location, keeping that single login. Screen + Irssi makes this possible. So, just at first glance, screen and Irssi are a dream come true... until I discovered Irssi proxy.
I read a lot of blogs and planets on the web, and the one theme that has been sticking out lately is using IRC effectively. This means more than just connecting when you need something, and disconnecting when you're done. Managing an IRC connection, and having the power over that connection to implement encryption, use any client you wish, and stay connected, thus, staying visible and available for someone who needs you.
Before I get into the nitty-gritty on setting it up, let me explain what it is. Irssi-proxy is effectively an IRC bouncer, with a few extra perks. First, launch up Irssi inside of screen as you normally would, then enable the proxy. With the proxy running, you now have the power to point any IRC client to the IP address and port of the proxy, both locally, and remotely. For example:
I have Irssi running now. However, I prefer to have all my instant communication in one application, such as Gaim, rather than separating it out. So, I enable the Irssi proxy plugin and tell it the port to listen on. Now, just for kicks, I'm not on the same computer that is running Irssi, as such, I need a way to access the port on that local machine. In walk SSH tunnel. I create an SSH tunnel between the remote computer running the Irssi proxy, and my local machine that I am going to start Gaim with. Once the tunnel is created, I then point Gaim to use localhost on the tunnel port for SSH. Before you can say "Bob is your uncle", I am now connected to my Irssi session with Gaim, and the whole process is transparent to anyone in the channels I'm in.
Let's look at this in closer detail, with a detailed how-to. First, run Irssi inside of screen. This should be a no-brainer.
aaron@achiles:~$ screen irssi
Next, connect to your server of choice, in this case Freenode. You will need to add Freenode to your server list, and take note to what you call the network. For example, in Irssi:
/server add -auto freenode irc.freenode.net 6667 password
In this case, I called the network "freenode". Whatever you call your network, you will need to remember it, as it is needed in this next step with the proxy. First we need to load the proxy module. It's important to note, also, that Irssi needs to be compiled with this module. Otherwise, you'll have to do it yourself, or use another proxy. In the case of Ubuntu and Debian, the proxy is built into the binary. Once loaded, we need to set a password, and tell the proxy what ports we want the client running on for each server. Yes, if you connect to multiple servers, you will have to tell it a separate port for every server. Follow the example below (where 'secret' is just some password):
/load proxy /set irssiproxy_password secret /set irssiproxy_ports freenode=3333
Ok. I've just told the Irssi proxy to listen on port 3333 for the 'freenode' network, which holds the physical connection on 6667. So, on the box running Irssi, I can load any local IRC client, point it to localhost:3333, and I can take advantage of the Irssi proxy. However, I want to run Gaim on a different computer than Irssi, so pointing it to localhost:3333 won't work. Unless, I create an SSH tunnel. This is easy:
aaron@achiles:~$ ssh -L 6667:localhost:3333 email@example.com
Easy as pie. From here, I can now point my local IRC client, in this case Gaim, to localhost:6667, and it will translate to localhost:3333 on the remote machine, where Irssi proxy is running. Irssi will accept the connection, and now Gaim is connected to my Irssi connection, using it as a bouncer to the Freenode network. And all I really did was:
- Load Irssi in screen
- Start up the Irssi proxy
- Create an SSH tunnel to the remote box running the proxy
- Point my local client to the SSH tunnel
4 easy steps. The great thing? Irssi will accept as many connections as you like. This means, I can be running a local client on my home desktop, a local client on my laptop, and local client on my work box and a local client at school. Heck, I could have multiple connections on just one machine: Gaim, XChat, Mirc, Trillian, BitchX, etc all using the Irssi proxy. And with the SSH tunnel, everything is encrypted on the wire.
Ok, now that that is over with, let's look at why you would want to do this. First, the disadvantages:
- You need access to both an SSH client and an IRC client on the local machine.
- Even though you connect to Irssi with XChat, for example, and all the channels load up, the back history that Irssi may have from the channel is not available.
- It takes extra configuration to point the client to the right address and port, and some aren't intuitive or easy to do so.
However, with that said, there are a few advantages:
- Irssi is still available with all your channels and settings. After all, you are running Irssi on the remote machine.
- You can use any IRC client you like: GUI or text-based.
- You can access the session regardless of location, just as you can with SSH and screen.
- Using the SSH tunnel, everything is encrypted on the wire.
- The process is transparent to the channel users.
- Maintain a single connection, with multiple connections using the same nick.
I hope this makes sense. Basically, Irssi is running on machine A, and you are located on machine B. Launch as many clients as you like on machine B pointing to the SSH tunnel created between machine A and machine B. Do the same with machine C, D, E, F, etc. One true connection to the IRC server, and one nick is all that is needed.
The only problem I have found to this solution, is when you leave a channel on the local client (Gaim, for example), you also leave the channel in Irssi on the remote machine. This is a problem, because if you close your local IRC client, all the channels that you are in inside Irssi, you will leave. The only way around this, is to cut the SSH tunnel BEFORE exiting your IRC client. Thus keeping you in the channels without leaving. There has to be a way for Irssi to keep you in your channels when you close the local client, I just haven't figured that out as of yet.
Anyway, there are plenty of other tutorials and for each server how-tos on the web covering this very subject. It's where I learned how to do this. Hopefully, my tutorial made it a little bit easier, but if not, Google is your friend. And, of course, I'll help to the best of my ability.