Created
July 17, 2015 12:04
-
-
Save poige/a87761fff67d4960741e to your computer and use it in GitHub Desktop.
Revisions
-
poige created this gist
Jul 17, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/sh # # Tries to keep SSH-forwarding connection open for port forwarding # using given range of local ports. # UserHost='SPECIFY_USER@HOST.HERE' PortMin=20200 PortMax=20222 AliveChkSec=17 AliveChkCnt=3 Port="$PortMin" while :; do ssh \ -o UserKnownHostsFile=/dev/null \ -o StrictHostKeyChecking=no \ -o ServerAliveInterval="$AliveChkSec" \ -o ServerAliveCountMax="$AliveChkCnt" \ -o ExitOnForwardFailure=yes \ -C -R"$Port":127.0.0.1:22 \ "$UserHost" Port=$(($Port+1)) if [ "$Port" -gt "$PortMax" ]; then Port="$PortMin" fi done