Files
claudetools/infrastructure/setup-ssh-keys.ps1
Mike Swanson 06f7617718 feat: Major directory reorganization and cleanup
Reorganized project structure for better maintainability and reduced
disk usage by 95.9% (11 GB -> 451 MB).

Directory Reorganization (85% reduction in root files):
- Created docs/ with subdirectories (deployment, testing, database, etc.)
- Created infrastructure/vpn-configs/ for VPN scripts
- Moved 90+ files from root to organized locations
- Archived obsolete documentation (context system, offline mode, zombie debugging)
- Moved all test files to tests/ directory
- Root directory: 119 files -> 18 files

Disk Cleanup (10.55 GB recovered):
- Deleted Rust build artifacts: 9.6 GB (target/ directories)
- Deleted Python virtual environments: 161 MB (venv/ directories)
- Deleted Python cache: 50 KB (__pycache__/)

New Structure:
- docs/ - All documentation organized by category
- docs/archives/ - Obsolete but preserved documentation
- infrastructure/ - VPN configs and SSH setup
- tests/ - All test files consolidated
- logs/ - Ready for future logs

Benefits:
- Cleaner root directory (18 vs 119 files)
- Logical organization of documentation
- 95.9% disk space reduction
- Faster navigation and discovery
- Better portability (build artifacts excluded)

Build artifacts can be regenerated:
- Rust: cargo build --release (5-15 min per project)
- Python: pip install -r requirements.txt (2-3 min)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-18 20:42:28 -07:00

108 lines
3.3 KiB
PowerShell

# Setup Passwordless SSH Access to RMM Server
# This script configures SSH key authentication for automated deployments
param(
[string]$Password
)
$ErrorActionPreference = "Stop"
$RMM_HOST = "guru@172.16.3.30"
$SSH_PUB_KEY = Get-Content "$env:USERPROFILE\.ssh\id_rsa.pub"
Write-Host "[INFO] Setting up passwordless SSH access to RMM server..." -ForegroundColor Cyan
Write-Host ""
# Step 1: Copy public key to RMM server
Write-Host "[1/4] Copying SSH public key to RMM server..." -ForegroundColor Yellow
# Create temp file with public key
$tempKeyFile = "$env:TEMP\claude_ssh_key.pub"
$SSH_PUB_KEY | Out-File -FilePath $tempKeyFile -Encoding ASCII -NoNewline
# Copy to RMM server /tmp
if ($Password) {
# Use password if provided
$env:PLINK_PASSWORD = $Password
echo y | pscp -pw $Password $tempKeyFile "${RMM_HOST}:/tmp/claude_key.pub" 2>&1 | Out-Null
} else {
# Interactive password prompt
echo y | pscp $tempKeyFile "${RMM_HOST}:/tmp/claude_key.pub"
}
if ($LASTEXITCODE -ne 0) {
Write-Host "[ERROR] Failed to copy SSH key to server" -ForegroundColor Red
exit 1
}
Write-Host "[OK] Public key copied to /tmp/claude_key.pub" -ForegroundColor Green
Write-Host ""
# Step 2: Create .ssh directory on RMM server
Write-Host "[2/4] Creating .ssh directory on RMM server..." -ForegroundColor Yellow
if ($Password) {
plink -batch -pw $Password $RMM_HOST "mkdir -p ~/.ssh && chmod 700 ~/.ssh" 2>&1 | Out-Null
} else {
plink $RMM_HOST "mkdir -p ~/.ssh && chmod 700 ~/.ssh"
}
if ($LASTEXITCODE -ne 0) {
Write-Host "[WARNING] .ssh directory may already exist" -ForegroundColor Yellow
}
Write-Host "[OK] .ssh directory ready" -ForegroundColor Green
Write-Host ""
# Step 3: Append public key to authorized_keys
Write-Host "[3/4] Adding public key to authorized_keys..." -ForegroundColor Yellow
$setupCommand = @"
cat /tmp/claude_key.pub >> ~/.ssh/authorized_keys && \
chmod 600 ~/.ssh/authorized_keys && \
rm /tmp/claude_key.pub && \
echo 'SSH key installed successfully'
"@
if ($Password) {
plink -batch -pw $Password $RMM_HOST $setupCommand
} else {
plink $RMM_HOST $setupCommand
}
if ($LASTEXITCODE -ne 0) {
Write-Host "[ERROR] Failed to configure authorized_keys" -ForegroundColor Red
exit 1
}
Write-Host "[OK] Public key added to authorized_keys" -ForegroundColor Green
Write-Host ""
# Step 4: Test passwordless access
Write-Host "[4/4] Testing passwordless SSH access..." -ForegroundColor Yellow
Start-Sleep -Seconds 2
$testResult = plink -batch $RMM_HOST "echo 'Passwordless SSH working!'" 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "[SUCCESS] Passwordless SSH is configured!" -ForegroundColor Green
Write-Host ""
Write-Host "You can now use plink/pscp without passwords:" -ForegroundColor White
Write-Host " pscp file.txt ${RMM_HOST}:/tmp/" -ForegroundColor Gray
Write-Host " plink ${RMM_HOST} 'ls -l'" -ForegroundColor Gray
Write-Host ""
Write-Host "The deploy.ps1 script will now work without prompts." -ForegroundColor White
} else {
Write-Host "[ERROR] Passwordless SSH test failed" -ForegroundColor Red
Write-Host "Output: $testResult" -ForegroundColor Gray
exit 1
}
# Clean up
Remove-Item $tempKeyFile -ErrorAction SilentlyContinue
Write-Host ""
Write-Host "=" * 70 -ForegroundColor Green
Write-Host "SSH KEY AUTHENTICATION CONFIGURED" -ForegroundColor Green
Write-Host "=" * 70 -ForegroundColor Green