Files
claudetools/clients/dataforth/scripts/test-ssh-direct.ps1
Mike Swanson 5cbd49ce24 Reorganize repo: compartmentalize scripts by client/project
Move 150+ scripts from root and scripts/ into client/project directories:
- clients/dataforth/scripts/ (110 files: AD2, sync, SSH, DB, DOS scripts)
- clients/bg-builders/scripts/ (14 files: Lesley mgmt, Exchange, termination)
- clients/internal-infrastructure/scripts/ (10 files: GDAP, Gitea, backups)
- projects/msp-tools/scripts/ (9 files: CIPP, MSP onboarding, Datto)
- projects/gururmm-agent/scripts/ (3 files: API test, JWT, record counts)
- clients/glaztech/scripts/ (1 file: CentraStage removal)

Also reorganized:
- VPN scripts → infrastructure/vpn-configs/
- Retrieved API/JS files → api/
- Forum posts → projects/community-forum/forum-posts/
- SSH docs → clients/internal-infrastructure/docs/
- NWTOC/CTONW docs → projects/wrightstown-smarthome/docs/
- ACG website files → projects/internal/acg-website-2025/
- Dataforth docs → clients/dataforth/docs/
- schema-retrieved.sql → docs/database/

Deleted 24 tmp_*.ps1 one-off debug scripts (preserved in git history).
Root reduced from 220+ files to 62 items (docs + directories only).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:15:07 -07:00

57 lines
2.9 KiB
PowerShell

$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "Testing Direct SSH Execution from AD2..." -ForegroundColor Cyan
Write-Host ""
Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock {
Write-Host "[1] Checking known_hosts..." -ForegroundColor Yellow
$knownHosts = Get-Content "$env:USERPROFILE\.ssh\known_hosts" -ErrorAction SilentlyContinue
if ($knownHosts -match "192.168.0.9") {
Write-Host " [OK] NAS entry found in known_hosts" -ForegroundColor Green
} else {
Write-Host " [WARNING] NAS not in known_hosts" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "[2] Testing SSH with explicit key..." -ForegroundColor Yellow
$sshCmd = "C:\Program Files\OpenSSH\ssh.exe"
$sshKey = "$env:USERPROFILE\.ssh\id_ed25519"
Write-Host " Command: $sshCmd -i $sshKey -o ConnectTimeout=5 root@192.168.0.9 hostname" -ForegroundColor Gray
$process = Start-Process -FilePath $sshCmd -ArgumentList "-i",$sshKey,"-o","ConnectTimeout=5","-o","StrictHostKeyChecking=no","root@192.168.0.9","hostname" -NoNewWindow -Wait -PassThru -RedirectStandardOutput "$env:TEMP\ssh_test_out.txt" -RedirectStandardError "$env:TEMP\ssh_test_err.txt"
$stdout = Get-Content "$env:TEMP\ssh_test_out.txt" -ErrorAction SilentlyContinue
$stderr = Get-Content "$env:TEMP\ssh_test_err.txt" -ErrorAction SilentlyContinue
Write-Host " Exit code: $($process.ExitCode)" -ForegroundColor White
if ($stdout) { Write-Host " STDOUT: $stdout" -ForegroundColor Green }
if ($stderr) { Write-Host " STDERR: $stderr" -ForegroundColor Red }
Write-Host ""
Write-Host "[3] Testing with plink (PuTTY) if available..." -ForegroundColor Yellow
$plink = Get-Command plink -ErrorAction SilentlyContinue
if ($plink) {
Write-Host " Found plink at: $($plink.Source)" -ForegroundColor Green
$plinkResult = & plink -batch root@192.168.0.9 hostname 2>&1
Write-Host " Result: $plinkResult" -ForegroundColor White
} else {
Write-Host " Plink not found" -ForegroundColor Gray
}
Write-Host ""
Write-Host "[4] Testing SCP file transfer..." -ForegroundColor Yellow
$testFile = "$env:TEMP\test_scp_$(Get-Date -Format 'HHmmss').txt"
"TEST" | Out-File -FilePath $testFile -Encoding ASCII
$scpCmd = "C:\Program Files\OpenSSH\scp.exe"
$process = Start-Process -FilePath $scpCmd -ArgumentList "-o","ConnectTimeout=5","-o","StrictHostKeyChecking=no",$testFile,"root@192.168.0.9:/tmp/" -NoNewWindow -Wait -PassThru -RedirectStandardError "$env:TEMP\scp_test_err.txt"
$scpErr = Get-Content "$env:TEMP\scp_test_err.txt" -ErrorAction SilentlyContinue
Write-Host " SCP Exit code: $($process.ExitCode)" -ForegroundColor White
if ($scpErr) { Write-Host " SCP STDERR: $scpErr" -ForegroundColor Red }
Remove-Item $testFile -ErrorAction SilentlyContinue
}