Commit e02dabb1 by Rinat K. Nugaev

Function added

parent d2708b76
...@@ -13,9 +13,6 @@ ...@@ -13,9 +13,6 @@
# - Added better variables checking # - Added better variables checking
# - Changed users's array creating # - Changed users's array creating
# - Some functions trying to add ))) # - Some functions trying to add )))
user="" user=""
#Defining some colours for fun ))) #Defining some colours for fun )))
RED='\033[0;31m' RED='\033[0;31m'
...@@ -33,19 +30,28 @@ if [ -z "$user"] ; then ...@@ -33,19 +30,28 @@ if [ -z "$user"] ; then
else else
echo "Username defined! Trying to connect..." echo "Username defined! Trying to connect..."
fi fi
#Create function with port and name of hostname
function create_tunnel
{
ssh -f -N -o ExitOnForwardFailure=yes -p 10022 -L $1:$2.rbtechnologies.ru:3389 $user@tunnel01.rbtechnologies.ru
}
#Declaring array of tunnels #Declaring array of tunnels
declare -A tunnels declare -A tunnels
tunnels+=( ["iv176"]="ssh -f -N -o ExitOnForwardFailure=yes -p 10022 -L 5555:iv176.rbtechnologies.ru:3389 $user@tunnel01.rbtechnologies.ru" ["ks262"]="ssh -f -N -o ExitOnForwardFailure=yes -p 10022 -L 5556:ks261.rbtechnologies.ru:3389 $user@tunnel01.rbtechnologies.ru" ["vs1027"]="ssh -f -N -o ExitOnForwardFailure=yes -p 10022 -L 5557:vs1027.rbtechnologies.ru:3389 $user@tunnel01.rbtechnologies.ru" ) tunnels+=( ["iv176"]="5555" ["ks262"]="5556" ["vs1027"]="5557" )
#Connecting... #Connecting...
for conn in "${!tunnels[@]}"; do for conn in "${!tunnels[@]}"; do
if ${tunnels[$conn]} ; then if create_tunnel ${tunnels[$conn]} $conn ; then
echo -e "${GREEN}Tunnel to the DMZ host $conn succesufully created!${NC}" echo -e "${GREEN}Tunnel to the DMZ host $conn succesufully created!${NC}"
else else
echo -e "${RED}Tunnel creation to the $conn FAIL (((${NC}" echo -e "${RED}Tunnel creation to the $conn FAIL ${NC}"
fi fi
done done
exit 0 exit 0
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