# Controle: hoe staat deze pc ervoor? Verandert niets. # Gebruik: irm pc.bbnld.nl/controle | iex # Of lokaal: powershell -ExecutionPolicy Bypass -File C:\BBN-Support\pc-inrichten\controle.ps1 param([switch]$AlsDeel) $libLokaal = 'C:\BBN-Support\pc-inrichten\lib.ps1' if (Test-Path $libLokaal) { . $libLokaal } else { try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072 } catch { } Invoke-Expression (Invoke-RestMethod -Uri 'https://pc.bbnld.nl/bestanden/lib.ps1' -UseBasicParsing) } $ErrorActionPreference = 'Continue' $script:Uitkomst.Clear() $kitInfo = Lees-Kit $pc = Lees-Json $script:PcJson Kop "Controle $env:COMPUTERNAME" if ($pc.naam) { Goed "Naam: $($pc.naam) (Tailscale: $($pc.hostnaam), SSH-gebruiker: $($pc.sshGebruiker))" } else { Let 'C:\BBN-Support\pc.json ontbreekt: pc-inrichten is hier nog niet (helemaal) gedraaid' } $ts = Ts-Stand if (-not $ts) { Let 'Tailscale antwoordt niet' } elseif ($ts.BackendState -ne 'Running') { Let "Tailscale is niet verbonden (stand: $($ts.BackendState))" } else { Goed "Tailscale verbonden, adres $(Ts-Ip)" $prefs = Start-Native $script:TsExe @('debug', 'prefs') if ($prefs.Uitvoer -match '"ForceDaemon":\s*true') { Goed 'Tailscale blijft aan zonder aanmelden' } elseif ($prefs.Uitvoer -match '"ForceDaemon":\s*false') { Let 'Tailscale stopt als niemand is aangemeld (tailscale set --unattended=true)' } if ($ts.Self.KeyExpiry -and -not $ts.Self.Tags) { Info "Let op: Tailscale-aanmelding verloopt op $($ts.Self.KeyExpiry) (voor vaste pc: Disable key expiry in Tailscale)" } } $svc = Get-Service sshd -ErrorAction SilentlyContinue if ($svc -and $svc.Status -eq 'Running' -and $svc.StartType -eq 'Automatic') { Goed 'OpenSSH-server (sshd) draait en start vanzelf' } elseif ($svc) { Let "OpenSSH-server: stand $($svc.Status), starttype $($svc.StartType)" } else { Let 'OpenSSH-server staat er niet' } if (Test-Path $script:SleutelPad) { $n = @(Get-Content $script:SleutelPad | Where-Object { $_ -match 'ssh-(ed25519|rsa) ' }).Count Goed "Sleutels van onze servers: $n" } else { Let 'Sleutelbestand ontbreekt' } $cfg = Join-Path $script:SshData 'sshd_config' if ((Test-Path $cfg) -and (Select-String -Path $cfg -Pattern 'PasswordAuthentication no' -Quiet) -and (Select-String -Path $cfg -Pattern 'bbn_agent_authorized_keys' -Quiet)) { Goed 'SSH alleen met sleutel, geen wachtwoorden' } else { Let 'sshd_config is niet die van dit pakket' } $regel = Get-NetFirewallRule -Name $script:RegelNaam -ErrorAction SilentlyContinue if ($regel -and $regel.Enabled -eq 'True') { Goed "Firewall: poort 22 alleen vanaf $((($regel | Get-NetFirewallAddressFilter).RemoteAddress) -join ', ')" } else { Let 'Firewallregel voor SSH ontbreekt' } $luistert = Get-NetTCPConnection -LocalPort 22 -State Listen -ErrorAction SilentlyContinue if ($luistert) { Goed 'Poort 22 luistert' } else { Let 'Poort 22 luistert niet' } if (Test-Path (Join-Path $script:AgentMap 'pc-hulp\scherm.ps1')) { Goed 'Hulpjes voor de agent staan in C:\BBN-Support\agent' } else { Let 'Hulpjes voor de agent ontbreken' } $punten = @($script:Uitkomst | Where-Object { -not $_.ok }) Write-Host '' if ($punten.Count -eq 0) { Write-Host ' Alles in orde.' -ForegroundColor Green } else { Write-Host " $($punten.Count) punt(en) om na te lopen (zie LET OP hierboven)." -ForegroundColor Yellow } if (-not $AlsDeel -and $env:BBN_STIL -ne '1') { Write-Host '' Read-Host 'Druk op Enter om te sluiten' | Out-Null }