Skip to content

Instantly share code, notes, and snippets.

@charlesroper
Created March 21, 2024 01:16
Show Gist options
  • Save charlesroper/2c0ad809005c661ac16785b85bbc286c to your computer and use it in GitHub Desktop.
Save charlesroper/2c0ad809005c661ac16785b85bbc286c to your computer and use it in GitHub Desktop.
PowerShell script that starts an ssh SOCKS proxy then starts a browser. When the browser closes, it also closes the ssh proxy.
# Start the SSH command in the background
$sshProcess = Start-Process -FilePath "ssh" -ArgumentList "-v -D 1080 -N -C <SSH_SERVER>" -PassThru
# Wait for the SSH process to start
Start-Sleep -Seconds 2
# Start browser
Start-Process -FilePath "librewolf" -NoNewWindow
# Wait for browser to close
Wait-Process -Id (Get-Process librewolf).Id
# Terminate the SSH process
Stop-Process -Id $sshProcess.Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment