Created
October 7, 2014 19:35
-
-
Save logankimmel/0f81311f8afac9ccb581 to your computer and use it in GitHub Desktop.
Powershell to check for ssh connect, remote forward.
This file contains 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 characters
$global:restart = 1 | |
function getSsh { | |
$lines = (c:\cygwin64\bin\bash.exe -l -c "/bin/ps | grep ssh") | out-string | |
foreach ($line in $lines -split '[\r\n]') { | |
if ($line.Contains("ssh")) { | |
$global:restart = 0 | |
} | |
} | |
} | |
getSsh | |
if ($global:restart -eq 1) { | |
echo "!!!!! STARTING RDP !!!!!" | |
C:\cygwin64\bin\bash.exe -l -c "/bin/ssh -Nf -R 192.168.23.120:3389:localhost:3389 pi@192.168.23.120 >> /home/rdplogfile 2>&1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment