Skip to content

Instantly share code, notes, and snippets.

@NorthIsUp
Created March 28, 2013 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NorthIsUp/5259916 to your computer and use it in GitHub Desktop.
Save NorthIsUp/5259916 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Create a ssh tunnel to an ip for port or service
function tunnel (){
case "$2" in
"-h" | "--help" | "help")
echo "usage: $0 <service|port> ip"
echo "supported services:"
echo " psql, mysql"
;;
"psql")
ssh $1 -L 5434:127.0.0.1:5432
;;
"mysql")
ssh $1 -L 3306:127.0.0.1:3306
;;
*)
ssh $1 -L $2:127.0.0.1$2
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment