Skip to content

Instantly share code, notes, and snippets.

@oeo
Created February 5, 2026 22:47
Show Gist options
  • Select an option

  • Save oeo/19a0e95fe834b80cd03a2cd6de66e8d8 to your computer and use it in GitHub Desktop.

Select an option

Save oeo/19a0e95fe834b80cd03a2cd6de66e8d8 to your computer and use it in GitHub Desktop.
Setup ngrok tunnel for WSL SSH
# Setup ngrok tunnel for WSL SSH access
# Run this in PowerShell (as Administrator)
Write-Host "╔══════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ Setting up ngrok tunnel for WSL SSH ║" -ForegroundColor Cyan
Write-Host "╚══════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
Write-Host ""
# Check if ngrok is installed
if (!(Get-Command ngrok -ErrorAction SilentlyContinue)) {
Write-Host "[1/2] Installing ngrok..." -ForegroundColor Green
# Try winget first
if (Get-Command winget -ErrorAction SilentlyContinue) {
winget install ngrok.ngrok --silent
} else {
# Download manually
Write-Host " → Downloading ngrok..." -ForegroundColor White
$ngrokUrl = "https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-windows-amd64.zip"
$ngrokZip = "$env:TEMP\ngrok.zip"
$ngrokDir = "$env:USERPROFILE\ngrok"
Invoke-WebRequest -Uri $ngrokUrl -OutFile $ngrokZip
Expand-Archive -Path $ngrokZip -DestinationPath $ngrokDir -Force
# Add to PATH for this session
$env:Path += ";$ngrokDir"
Write-Host " ✓ ngrok installed to: $ngrokDir" -ForegroundColor White
Write-Host " → Add to PATH permanently: `$env:Path += `;$ngrokDir`"" -ForegroundColor Yellow
}
} else {
Write-Host "[1/2] ngrok already installed ✓" -ForegroundColor Green
}
Write-Host "[2/2] Starting ngrok tunnel on port 2222..." -ForegroundColor Green
Write-Host ""
Write-Host "╔══════════════════════════════════════════════════════════════╗" -ForegroundColor Yellow
Write-Host "║ ngrok will start and show a URL like: ║" -ForegroundColor Yellow
Write-Host "║ tcp://0.tcp.ngrok.io:12345 ║" -ForegroundColor Yellow
Write-Host "║ ║" -ForegroundColor Yellow
Write-Host "║ Share that URL with the person who needs to connect. ║" -ForegroundColor Yellow
Write-Host "║ Press Ctrl+C to stop the tunnel when done. ║" -ForegroundColor Yellow
Write-Host "╚══════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
Write-Host ""
Write-Host "Starting ngrok..." -ForegroundColor Cyan
Write-Host ""
# Start ngrok
ngrok tcp 2222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment