~dee

SSH tunnel for IRC

22/12/18 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: open_tilde_tunnel_sh: #!/bin/bash ssh -N -f tildeirc & echo $! > ~/.tilde_ssh_pid close_tilde_tunnel.sh: #!/bin/bash if [ -e ~/.tilde_ssh_pid ] then kill `cat ~/.tilde_ssh_pid` rm ~/.tilde_ssh_pid fi 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 Host tildeirc HostName tilde.town User YOUR_USERNAME LocalForward localhost:6667 localhost:6667 ServerAliveInterval 240 IdentityFile ~/.ssh/tilde.town 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: ~open 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: ~close This kills the tunnel by using the stored process id, and then deletes the file it was kept in.