SSH tunnel for IRC
Here's an overview of my setup:
My irc client is thelounge, running on my machine.
I want to connect to tilde.town IRC from it, so I have to establish an SSH tunnel.
To open and close the tunnel I use two aliases: "~open" and "~close":
alias ~close=sh close_tilde_tunnel.sh
alias ~open=sh open_tilde_tunnel.sh
The shell scripts these aliases run must be reachable, eg. if you're using Cmder you can put them under /bin/ in your cmder folder.
Contents of the scripts:
ssh -N -f tildeirc &
echo $! > ~/.tilde_ssh_pid
if [ -e ~/.tilde_ssh_pid ]
kill `cat ~/.tilde_ssh_pid`
The scripts are using a predefined ssh configuration we set in our ssh config.
You can create this by making a file named "config" under ~/.ssh/
(Replace "YOUR_USERNAME" with your username)
# tilde.town irc tunnel
LocalForward localhost:6667 localhost:6667
This setup presupposes that your private key for tilde.town is ~/.ssh/tilde.town.
Now that you have everything set up, you can open the tunnel:
And then open your irc client, and connect to tilde.town irc by connecting to localhost:6667.
This creates a file under ~ named ".tilde_ssh_pid" which contains the process id for the ssh tunnel.
When you're done using the tunnel, close it:
This kills the tunnel by using the stored process id, and then deletes the file it was kept in.