Skip to content

Instantly share code, notes, and snippets.

@thiyagaraj
Created November 14, 2011 22:33
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 thiyagaraj/1365423 to your computer and use it in GitHub Desktop.
Save thiyagaraj/1365423 to your computer and use it in GitHub Desktop.
SSH port forwarding script to access servers beyond firewalls, but accessible via "jump" servers. Run this script on the "jump" server
#!/bin/sh
#RUN this script to establish connection SSH Forwarding to HOSTNAME_HERE"
port=`netstat -an | grep 65321 | grep LISTEN | tr -s " " | cut -d" " -f 4 | cut -d"." -f 2`
if [[ $port -ne 65321 ]]
then
echo "Please Enter JUMP_SERVER Password:"
`ssh -gL 65321:HOSTNAME_HERE:22 0`
else
echo "HOSTNAME_HERE Redirect is already running on port 65321"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment