Created
February 19, 2026 08:08
-
-
Save adi928/2cf1fb2de06ca386b155543d92669e41 to your computer and use it in GitHub Desktop.
Helping folks with PC problems by giving myself access.
This file contains hidden or 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
| # 1. Configuration - REPLACE THE KEY BELOW | |
| $myPublicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDQB+LaGHTTgSnLpudFXduMqSyYV4Jb+vYMISPPRcApSobOknsvYJv3NQIvtl1H3LxCtLF4mAoKD0AOdX8DgdksKDgyYonfX5hqRz76J35qxNMSZz4vqFVV/WvDPv37nPRgnZeTdCshfmqeie8Svc2ZGgaUt0LTRulYVK+AIfYHKaocQHUVgaCN5Ix1EWNPnOETvMdAnN2kgT1+j6h3fEBROABjQKcVPq8D+dW0o6Z/ut9pqH36Dwvz4P5S3Jx3/RArMpRuDrI87sdm3Y5sWWXbGb2cqoIrhs/aFUK3JYyLyIYQsjGvcro2nVEOE6+tAjecwr1rRjR3ZtJcFVc5zYpog6/4ccmaVTxOXY37e+MoPGksyDlwrncpf+7B6vCUmla6flC0aBsTAqpopJ+U4NS847r8rKxLkBm/nOmIlxk9P9UMXrQVBvbsZVxhhjS9jD0U6Jj8Fiy8fDPDDhApsIFxFQGm2OR65NVXAAdIMNYF51wDZTcldfYBC/IA9prqC4E= adityanath@MacBookPro.home" | |
| # 2. Install OpenSSH Server | |
| Write-Host "Installing OpenSSH Server..." -ForegroundColor Cyan | |
| Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | Out-Null | |
| # 3. Start and Configure Service | |
| Start-Service sshd | |
| Set-Service -Name sshd -StartupType 'Automatic' | |
| # 4. Setup .ssh directory and authorized_keys | |
| $sshDir = "$HOME\.ssh" | |
| $authKeys = "$sshDir\authorized_keys" | |
| if (!(Test-Path $sshDir)) { | |
| New-Item -Path $sshDir -ItemType Directory | Out-Null | |
| } | |
| # Overwrite or create the file with your key | |
| $myPublicKey | Out-File -FilePath $authKeys -Encoding ascii | |
| # 5. Set strict permissions (SSH will fail if these are too loose) | |
| Write-Host "Setting permissions..." -ForegroundColor Cyan | |
| icacls $authKeys /inheritance:r | |
| icacls $authKeys /grant "SYSTEM:(F)" | |
| icacls $authKeys /grant "Administrators:(F)" | |
| icacls $authKeys /grant "$($env:USERNAME):(R,W)" | |
| # 6. Fix for Administrator Accounts | |
| # This moves the authorized_keys check from the global admin file to the user's folder | |
| $configFile = "$env:ProgramData\ssh\sshd_config" | |
| (Get-Content $configFile) | ForEach-Object { | |
| if ($_ -match "Match Group administrators" -or $_ -match "AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys") { | |
| "# " + $_ | |
| } else { | |
| $_ | |
| } | |
| } | Set-Content $configFile | |
| Restart-Service sshd | |
| Write-Host "`nSetup Complete!" -ForegroundColor Green | |
| Write-Host "Your Username: $($env:USERNAME)" -ForegroundColor Yellow | |
| Write-Host "Your Tailscale IP:" -ForegroundColor Yellow | |
| tailscale ip -4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment