# Setup OpenSSH Server and Auto-Login # Run as Administrator in PowerShell $Username = if ($env:REGO_USER) { $env:REGO_USER } else { $env:USERNAME } $Password = if ($env:REGO_PASS) { $env:REGO_PASS } else { "admin" } Write-Host "=== Setting up OpenSSH Server ===" -ForegroundColor Cyan Write-Host "Using username: $Username" -ForegroundColor Yellow # Install OpenSSH Server $sshCapability = Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Server*' if ($sshCapability.State -ne 'Installed') { Write-Host "Installing OpenSSH Server..." -ForegroundColor Yellow Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 } else { Write-Host "OpenSSH Server already installed" -ForegroundColor Green } # Start and enable SSH service Write-Host "Starting SSH service..." -ForegroundColor Yellow Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic' # Configure firewall $fwRule = Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue if (-not $fwRule) { Write-Host "Adding firewall rule..." -ForegroundColor Yellow New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 } Write-Host "OpenSSH Server configured!" -ForegroundColor Green Write-Host "" Write-Host "=== Setting up Auto-Login ===" -ForegroundColor Cyan $RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" Set-ItemProperty -Path $RegPath -Name "AutoAdminLogon" -Value "1" Set-ItemProperty -Path $RegPath -Name "DefaultUserName" -Value $Username Set-ItemProperty -Path $RegPath -Name "DefaultPassword" -Value $Password Remove-ItemProperty -Path $RegPath -Name "DefaultDomainName" -ErrorAction SilentlyContinue Write-Host "Auto-login configured for '$Username'!" -ForegroundColor Green Write-Host "" Write-Host "Setup complete! SSH is now available and auto-login is enabled." -ForegroundColor Green Write-Host "Reboot to test auto-login." -ForegroundColor Yellow