-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_license_tunnel_script.sh
More file actions
executable file
·55 lines (46 loc) · 1.52 KB
/
create_license_tunnel_script.sh
File metadata and controls
executable file
·55 lines (46 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
tunnel_script=$1
rm -f ${HOME}/.ssh/config
cat >> ${HOME}/.ssh/config <<HERE
Host *
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
Host usercontainer
IdentityFile /home/${PW_USER}/.ssh/pw_id_rsa
HostName localhost
User ${PW_USER}
Port 2222
HERE
source resources/host/inputs.sh
echo '#!/bin/bash' > ${tunnel_script}
chmod +x ${tunnel_script}
cat resources/host/inputs.sh >> ${tunnel_script}
cat >> ${tunnel_script} <<HERE
# Check if SSH access is available using the jumphost
ssh -q -o BatchMode=yes -J usercontainer ${resource_ssh_usercontainer_options} ${gt_license_user}@${gt_license_ip} exit
# Exit if SSH connection fails
if [ \$? -ne 0 ]; then
echo; echo
echo "ERROR: Controller has no SSH access to the license server."
echo " ssh -J usercontainer ${resource_ssh_usercontainer_options} ${gt_license_user}@${gt_license_ip}"
exit 1
fi
echo "Creating tunnel with autossh"
ssh -J usercontainer \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=5 \
-o ConnectTimeout=10 \
-o ExitOnForwardFailure=yes \
-o TCPKeepAlive=yes \
-o ConnectionAttempts=5 \
-fN \
-L 0.0.0.0:${gt_license_port}:localhost:${gt_license_port} \
-L 0.0.0.0:${gt_license_vendor_port}:localhost:${gt_license_vendor_port} \
${gt_license_user}@${gt_license_ip} </dev/null &>/dev/null &
sleep 5
echo
echo "License server ports"
netstat -tuln | grep "${gt_license_port}\|${gt_license_vendor_port}"
HERE