From e016f6ebdd524ec326cdef3d9b071eec6298bce5 Mon Sep 17 00:00:00 2001 From: hiroTochigi Date: Wed, 19 Jun 2024 21:19:21 -0500 Subject: [PATCH] open ssh tunnel from ssh/config --- src/aws/dependencies/reverseShell.sh | 6 ++++-- src/aws/driver.sh | 2 +- src/aws/init.sh | 3 +-- src/aws/restart.sh | 1 - src/utils/dependencies/config.sh | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/aws/dependencies/reverseShell.sh b/src/aws/dependencies/reverseShell.sh index 8eaeb408..a0714d78 100755 --- a/src/aws/dependencies/reverseShell.sh +++ b/src/aws/dependencies/reverseShell.sh @@ -72,9 +72,11 @@ function openSSHTunnel(){ ssh -i /root/.ssh/$sshkey root@$instanceIp 'screen -m -d bash -c "service ssh restart"' sleep 2 - treehouses sshtunnel add host "$monitorPort" root@"$instanceIp" + #treehouses sshtunnel add host "$monitorPort" root@"$instanceIp" #deleteUnusedSShtunnel $instanceIp $sshtunnelPortArray - openNonDefaultSShtunnel $instanceIp $sshtunnelPortArray + #openNonDefaultSShtunnel $instanceIp $sshtunnelPortArray + createSshConfig "myserver" $instanceIp "user" "22" "~/.ssh/id_rsa" "8888:80,9999:443" + autossh -f -T -N -q -4 -M 2200 myserver echo "Below sshtunnels are configured" treehouses sshtunnel ports diff --git a/src/aws/driver.sh b/src/aws/driver.sh index e26e3a53..b3c34077 100755 --- a/src/aws/driver.sh +++ b/src/aws/driver.sh @@ -34,7 +34,7 @@ function awsDriver() { installAwsCli "${@:2}" ;; test) - testConfigDriver + testConfigDriver "${@:2}" ;; *) echo "Error: Invalid command." diff --git a/src/aws/init.sh b/src/aws/init.sh index 084bddc6..fc609d99 100644 --- a/src/aws/init.sh +++ b/src/aws/init.sh @@ -188,8 +188,7 @@ function init { isOpen=$(waitForOutput "ssh-keyscan -H $publicIp | grep ecdsa-sha2-nistp256") echo "Opened ssh tunnel" - updateOrAppend $instanceName $publicIp - openSSHTunnel $instanceName $portConfigArray + openSSHTunnel $publicIp $portConfigArray storeConfigIntoTreehousesConfigAsStringfiedJson $instanceName $keyName $instanceId $publicIp $groupName } diff --git a/src/aws/restart.sh b/src/aws/restart.sh index 3ecde38d..a9f04b27 100644 --- a/src/aws/restart.sh +++ b/src/aws/restart.sh @@ -30,5 +30,4 @@ function restart(){ echo "the new ip address is $publicIp" updateIPAddress $balloonName $publicIp - updateOrAppend $instanceName $publicIp } \ No newline at end of file diff --git a/src/utils/dependencies/config.sh b/src/utils/dependencies/config.sh index 892cb196..df85a563 100644 --- a/src/utils/dependencies/config.sh +++ b/src/utils/dependencies/config.sh @@ -1,2 +1,2 @@ -#CONFIG=~/.ssh/config -CONFIG=~/Projects/luftballon/config # Test +CONFIG=~/.ssh/config +#CONFIG=~/Projects/luftballon/config # Test