SSH Port Forward a local IRC server to the remote server

port-forwardingssh

So, I have this slight dilemma: I am not allowed to host an IRC server on my VPS, but I am allowed to use tunneling of some sort to let users connect to an IRC server I have set up locally on my Mac Mini.

Basically – how would I go about tunneling connections to port 6667 of my VPS to my Mac Mini without opening a port in my router (that's what I get for having a technically inclined dad)? I've read up a little on SSH port forwarding, but after about 3 hours of constant googling and trying things out, I just can't seem to get it to work. I've also been considering things like Himmachi(or whatever it's actually called now) and then somehow route the Himmachi IP of my Mac Mini to be public.

I know that my writing probably sounds hopelessly confused, but that's because I'm hopelessly confused as to where I could go from here.

I'd appreciate any help in this subject.

Best Answer

You need a reverse tunnel.

From your mac you ssh to your linux VPS, creating a reverse tunnel.

ssh -R *:6667:127.0.0.1:6667 tristan@linux

That connects from your mac-mini to your linux VPS. It makes ssh listen on all interfaces (*) on port 6667. Any traffic it finds (on port 6667 of your VPS) it sucks down the tunnel and punts back into the localhost on your mac-mini (127.0.0.1) onto port 6667.

You can also use,

ssh -f -N -R *:6667:127.0.0.1:6667 tristan@linux

so that you don't see a terminal session (-f backgrounds ssh after asking for your password, and the -N stops it running a remote command). To close the tunnel you'll need to find the process on your mac and kill it.

DCC operations won't work properly, but IRC might.

Caveat: I do not know if this will work for more than one IRC user connection

Note: Depending on why you've been told you can't run an IRC Daemon on your VPS, this technique might be an issue as well (i.e. if port 6667 is blocked inbound to your VPS).

On the VPS, you need to ensure GatewayPorts is enabled in the sshd_config file (usually /etc/ssh/sshd_config).

Related Question