Script for ssh port forwarding

Day to day I need to use ssh port forwarding and connect securely to my work servers. So I decided to create some simple bash script which will allow me to forward port via ssh and to kill previous tunnel if it freezed.

Script source:


#!/bin/bash
# irc.sh
kill -9 `ps -aef | grep -i 'ssh -f -N -L 1234:127.0.0.1:1234 user@hostname.com' | grep -v grep | awk '{print $2}'`
ssh -f -N -L 1234:127.0.0.1:1234 user@hostname.com

Continue reading