Skip to content

Instantly share code, notes, and snippets.

@logankimmel
Created October 7, 2014 19:35
Show Gist options
  • Save logankimmel/0f81311f8afac9ccb581 to your computer and use it in GitHub Desktop.
Save logankimmel/0f81311f8afac9ccb581 to your computer and use it in GitHub Desktop.
Powershell to check for ssh connect, remote forward.
$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