Skip to content

Instantly share code, notes, and snippets.

@ciekawy
Created March 2, 2026 13:52
Show Gist options
  • Select an option

  • Save ciekawy/1a46030cf45074727b6452f0b054b428 to your computer and use it in GitHub Desktop.

Select an option

Save ciekawy/1a46030cf45074727b6452f0b054b428 to your computer and use it in GitHub Desktop.
WEB-9: SSH-only setup for Windows Server 2022
# WEB-9: SSH Setup Only (for when main script fails)
# Run these commands one by one in PowerShell as Administrator
Write-Host "Installing OpenSSH Server..." -ForegroundColor Cyan
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Write-Host "Starting SSH service..." -ForegroundColor Cyan
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic
Write-Host "Configuring firewall..." -ForegroundColor Cyan
New-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -DisplayName "OpenSSH Server" -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
Write-Host "Adding SSH public key..." -ForegroundColor Cyan
$key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO9VR+9HrxMs+2NxN2h8Td6rCDP8eupti1BtqFK1pSdX coder@myfirst"
$file = "C:\ProgramData\ssh\administrators_authorized_keys"
New-Item -Path $file -ItemType File -Force -Value $key
icacls $file /inheritance:r
icacls $file /grant "SYSTEM:(F)"
icacls $file /grant "BUILTIN\Administrators:(F)"
Write-Host "Verifying SSH service..." -ForegroundColor Cyan
Get-Service sshd
Write-Host ""
Write-Host "✅ SSH configured!" -ForegroundColor Green
Write-Host "Test from Linux: ssh Administrator@46.224.201.14" -ForegroundColor Yellow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment