Commit ed3ff86c authored by Russell D's avatar Russell D

Added socket_setup V.15

parent dabf489a
#!/bin/bash
# socketsetup - remote access behind NAT
# version .121
# version .15
#
#
......@@ -9,10 +8,6 @@
pids=$( ps faux | grep -i a2cyber | grep -v grep | awk '{ print $2 }' )
npids=$( echo "$pids" | wc -w )
echo $npids
echo $pids
if [ "$npids" -ne 0 ]
......@@ -20,16 +15,32 @@ then
if [ "$npids" -ge "3" ]
then
kill -9 ` ps faux | grep -i a2cyber | grep -v grep | awk '{ print $2 }' `
#kill current ssh connections
if [ "$?" -eq 0 ]
then
echo -en "we killed these pids: $pids....."
else
echo -en "We couldn't kill the pids... unclean exit"
exit 1
fi
fi
if [ "$npids" -eq "2" ]
then
echo -en "\nSSH session is alive. Clean run `date`.\n"
exit 0
fi
else
screen -dm ssh -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 7001:localhost:22 -p 53 jumpman@a2cybersecurity.com
#establish a new connection to the jumpbox
#establish a new ssh session to the bastion host
screen -dm ssh -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 9001:localhost:22 -p 53 jumpman@a2cybersecurity.com
nnpids=$( ps faux | grep -i a2cyber | grep -v grep | awk '{ print $2 }' | wc -w )
if [ "$nnpids" -eq 2 ]
then
echo -en "We established a new ssh session to a2 through port 7001. `date`"
else
echo -en "Something went wrong, there is "$nnpids" ssh connections running to the bastion.. `date`"
fi
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment