diff --git a/.devcontainer/scripts/install-cert-via-ssh.fish b/.devcontainer/scripts/install-cert-via-ssh.fish new file mode 100644 index 0000000000..395c615312 --- /dev/null +++ b/.devcontainer/scripts/install-cert-via-ssh.fish @@ -0,0 +1,27 @@ +#!/usr/bin/env fish +# Install SSL certificate on Windows host via SSH + +echo "๐Ÿ“œ Installing certificate on Windows host via SSH..." +echo "" + +# Check if SSH is configured +if not ssh -o ConnectTimeout=3 windows-host "echo OK" >/dev/null 2>&1 + echo "โŒ SSH to windows-host not configured" + echo "" + echo "Run this first: fish /workspaces/aesthetic-computer/.devcontainer/scripts/setup-ssh-to-windows.fish" + echo "Then follow the Windows setup instructions" + exit 1 +end + +# Copy certificate to Windows temp +echo "๐Ÿ“‹ Copying certificate to Windows..." +scp /workspaces/aesthetic-computer/ssl-dev/rootCA.pem windows-host:"%TEMP%\\mkcert-rootCA.pem" + +# Install certificate +echo "๐Ÿ“œ Installing certificate in Windows Trust Store..." +ssh windows-host 'powershell.exe -Command "Import-Certificate -FilePath \"$env:TEMP\\mkcert-rootCA.pem\" -CertStoreLocation Cert:\\LocalMachine\\Root; Remove-Item \"$env:TEMP\\mkcert-rootCA.pem\""' + +echo "" +echo "โœ… Certificate installed on Windows!" +echo "" +echo "โš ๏ธ Please RESTART your browser (fully close Chrome and reopen)" diff --git a/.devcontainer/scripts/setup-ssh-to-windows.fish b/.devcontainer/scripts/setup-ssh-to-windows.fish new file mode 100755 index 0000000000..a238fdbf95 --- /dev/null +++ b/.devcontainer/scripts/setup-ssh-to-windows.fish @@ -0,0 +1,88 @@ +#!/usr/bin/env fish +# Setup SSH connection from devcontainer to Windows host + +echo "๐ŸชŸ Setting up SSH to Windows host..." +echo "" + +# Detect Windows host IP (usually the Docker gateway) +set WINDOWS_IP (ip route | grep default | awk '{print $3}') +echo "Windows host IP: $WINDOWS_IP" + +# Check if SSH keys exist +if not test -f ~/.ssh/id_ed25519 + and not test -f ~/.ssh/id_rsa + echo "" + echo "๐Ÿ“ No SSH key found. Generating one..." + ssh-keygen -t ed25519 -C "devcontainer@aesthetic-computer" -f ~/.ssh/id_ed25519 -N "" + echo "โœ… SSH key generated!" +end + +# Determine which key to use +set SSH_KEY_FILE "" +if test -f ~/.ssh/id_ed25519.pub + set SSH_KEY_FILE ~/.ssh/id_ed25519.pub +else if test -f ~/.ssh/id_rsa.pub + set SSH_KEY_FILE ~/.ssh/id_rsa.pub +end + +echo "" +echo "๐Ÿ“‹ Your public key:" +echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”" +cat $SSH_KEY_FILE +echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”" + +echo "" +echo "๐Ÿ“ Next steps on Windows (run PowerShell as Administrator):" +echo "" +echo "1. Run the setup script:" +echo " powershell -ExecutionPolicy Bypass -File (wslpath -w /workspaces/aesthetic-computer/.devcontainer/scripts/setup-windows-ssh.ps1)" +echo "" +echo "2. Or manually:" +echo " - Make sure OpenSSH Server is installed and running" +echo " - Create C:\\ProgramData\\ssh\\administrators_authorized_keys" +echo " - Add the public key above to that file" +echo " - Set permissions (see setup-windows-ssh.ps1)" +echo "" + +# Create SSH config entry +set SSH_CONFIG ~/.ssh/config +echo "" +echo "๐Ÿ”ง Adding SSH config for Windows host..." + +# Check if entry already exists +if grep -q "Host windows-host" $SSH_CONFIG 2>/dev/null + echo "โš ๏ธ SSH config entry already exists, skipping..." +else + # Create config file if it doesn't exist + touch $SSH_CONFIG + chmod 600 $SSH_CONFIG + + # Add Windows host entry + echo "" >> $SSH_CONFIG + echo "# Windows Docker Host" >> $SSH_CONFIG + echo "Host windows-host" >> $SSH_CONFIG + echo " HostName $WINDOWS_IP" >> $SSH_CONFIG + echo " User $USER" >> $SSH_CONFIG + if test -f ~/.ssh/id_ed25519 + echo " IdentityFile ~/.ssh/id_ed25519" >> $SSH_CONFIG + else + echo " IdentityFile ~/.ssh/id_rsa" >> $SSH_CONFIG + end + echo " IdentitiesOnly yes" >> $SSH_CONFIG + echo " StrictHostKeyChecking no" >> $SSH_CONFIG + + echo "โœ… SSH config updated!" +end + +echo "" +echo "๐Ÿงช Testing connection (this will fail until you complete Windows setup)..." +ssh -o ConnectTimeout=5 windows-host "echo 'Connected successfully!'" 2>&1 +or echo "โŒ Connection failed - complete Windows setup steps above first" + +echo "" +echo "๐Ÿ’ก After setup, you can connect with:" +echo " ssh windows-host" +echo " ssh windows-host 'dir C:\\'" +echo "" +echo "๐Ÿง  For Emacs MCP integration, you can use emacs_send_keys to execute:" +echo " ssh windows-host 'powershell.exe -Command \"\"'" diff --git a/.devcontainer/scripts/setup-windows-ssh.ps1 b/.devcontainer/scripts/setup-windows-ssh.ps1 new file mode 100644 index 0000000000..36dd9c6bfe --- /dev/null +++ b/.devcontainer/scripts/setup-windows-ssh.ps1 @@ -0,0 +1,48 @@ +# Setup OpenSSH Server on Windows +# Run this in PowerShell as Administrator + +Write-Host "๐Ÿ”ง Setting up OpenSSH Server on Windows..." -ForegroundColor Cyan + +# Install OpenSSH Server +Write-Host "`n๐Ÿ“ฆ Installing OpenSSH Server..." +Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 + +# Start and enable SSH service +Write-Host "`n๐Ÿš€ Starting SSH service..." +Start-Service sshd +Set-Service -Name sshd -StartupType 'Automatic' + +# Configure firewall +Write-Host "`n๐Ÿ”ฅ Configuring firewall..." +if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue)) { + New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' ` + -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 +} + +# Set PowerShell as default shell (optional but recommended) +Write-Host "`n๐Ÿš Setting PowerShell as default SSH shell..." +New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell ` + -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ` + -PropertyType String -Force + +# Create .ssh directory for authorized_keys +$sshDir = "$env:PROGRAMDATA\ssh" +if (!(Test-Path $sshDir)) { + New-Item -ItemType Directory -Path $sshDir +} + +Write-Host "`nโœ… OpenSSH Server setup complete!" -ForegroundColor Green +Write-Host "" +Write-Host "Next steps:" -ForegroundColor Yellow +Write-Host "1. Copy your public key from the devcontainer:" +Write-Host " cat ~/.ssh/id_ed25519.pub # or id_rsa.pub" +Write-Host "" +Write-Host "2. Add it to: C:\ProgramData\ssh\administrators_authorized_keys" +Write-Host " (Create the file if it doesn't exist)" +Write-Host "" +Write-Host "3. Set proper permissions on administrators_authorized_keys:" +Write-Host ' icacls "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r' +Write-Host ' icacls "C:\ProgramData\ssh\administrators_authorized_keys" /grant SYSTEM:(F)' +Write-Host ' icacls "C:\ProgramData\ssh\administrators_authorized_keys" /grant BUILTIN\Administrators:(F)' +Write-Host "" +Write-Host "Your Windows IP (from container): 172.17.0.1" diff --git a/.devcontainer/scripts/windows-exec.fish b/.devcontainer/scripts/windows-exec.fish new file mode 100755 index 0000000000..0e9ab5f881 --- /dev/null +++ b/.devcontainer/scripts/windows-exec.fish @@ -0,0 +1,16 @@ +#!/usr/bin/env fish +# Execute commands on Windows host via SSH +# Usage: windows-exec.fish "powershell command here" + +if test (count $argv) -eq 0 + echo "Usage: windows-exec.fish \"command\"" + echo "" + echo "Examples:" + echo " windows-exec.fish 'dir C:\\'" + echo " windows-exec.fish 'powershell.exe -Command \"Get-Process\"'" + echo " windows-exec.fish 'powershell.exe -File C:\\path\\to\\script.ps1'" + exit 1 +end + +# Execute command on Windows host +ssh windows-host $argv diff --git a/ssl-dev/install-cert-docker.ps1 b/ssl-dev/install-cert-docker.ps1 new file mode 100644 index 0000000000..6b1999b0ab --- /dev/null +++ b/ssl-dev/install-cert-docker.ps1 @@ -0,0 +1,52 @@ +# Install mkcert CA root certificate from Docker container +# Run this in PowerShell as Administrator + +Write-Host "๐Ÿ” Finding Docker container..." -ForegroundColor Cyan + +# Get the container ID/name for the aesthetic-computer workspace +$container = docker ps --filter "label=devcontainer.local_folder" --format "{{.Names}}" | Select-Object -First 1 + +if (-not $container) { + # Try finding by image or volume + $container = docker ps --format "{{.Names}}" | Where-Object { $_ -match "aesthetic" } | Select-Object -First 1 +} + +if (-not $container) { + Write-Host "โŒ Could not find Docker container." -ForegroundColor Red + Write-Host "" + Write-Host "๐Ÿ“‹ Manual steps:" -ForegroundColor Yellow + Write-Host "1. Find your container name: docker ps" + Write-Host "2. Copy the certificate:" + Write-Host ' docker cp :/workspaces/aesthetic-computer/ssl-dev/rootCA.pem $env:TEMP\rootCA.pem' + Write-Host "3. Import it:" + Write-Host ' Import-Certificate -FilePath $env:TEMP\rootCA.pem -CertStoreLocation Cert:\LocalMachine\Root' + Write-Host "4. Restart your browser" + exit 1 +} + +Write-Host "โœ… Found container: $container" -ForegroundColor Green + +# Copy the certificate from the container +$tempCert = "$env:TEMP\mkcert-rootCA.pem" +Write-Host "๐Ÿ“‹ Copying certificate from container..." -ForegroundColor Cyan + +docker cp "${container}:/workspaces/aesthetic-computer/ssl-dev/rootCA.pem" $tempCert + +if (Test-Path $tempCert) { + Write-Host "๐Ÿ“œ Installing mkcert CA root certificate into Windows Trust Store..." -ForegroundColor Cyan + Import-Certificate -FilePath $tempCert -CertStoreLocation Cert:\LocalMachine\Root + Remove-Item $tempCert + Write-Host "" + Write-Host "โœ… CA root certificate installed successfully!" -ForegroundColor Green + Write-Host "" + Write-Host "โš ๏ธ IMPORTANT: Fully close and restart Chrome for changes to take effect." -ForegroundColor Yellow + Write-Host " (Don't just refresh - close ALL Chrome windows and reopen)" -ForegroundColor Yellow + Write-Host "" + Write-Host "Your HTTPS URLs should now work:" -ForegroundColor Cyan + Write-Host " โ€ข https://localhost:8888" + Write-Host " โ€ข https://localhost:3002" + Write-Host " โ€ข https://localhost:8889" +} else { + Write-Host "โŒ Failed to copy certificate from container." -ForegroundColor Red + Write-Host "Container path: /workspaces/aesthetic-computer/ssl-dev/rootCA.pem" +} diff --git a/ssl-dev/install-cert-windows.ps1 b/ssl-dev/install-cert-windows.ps1 new file mode 100644 index 0000000000..5aae2226e3 --- /dev/null +++ b/ssl-dev/install-cert-windows.ps1 @@ -0,0 +1,46 @@ +# Install mkcert CA root certificate into Windows Trust Store +# Run this in PowerShell as Administrator + +# First, copy the cert from the container/volume to a temp location +$tempCert = "$env:TEMP\mkcert-rootCA.pem" + +# Try multiple possible paths +$possiblePaths = @( + "\\wsl.localhost\Ubuntu\workspaces\aesthetic-computer\ssl-dev\rootCA.pem", + "\\wsl$\Ubuntu\workspaces\aesthetic-computer\ssl-dev\rootCA.pem" +) + +$certPath = $null +foreach ($path in $possiblePaths) { + if (Test-Path $path) { + $certPath = $path + break + } +} + +if ($certPath) { + Write-Host "๐Ÿ“œ Found certificate at: $certPath" -ForegroundColor Green + Copy-Item $certPath $tempCert -Force + Write-Host "๐Ÿ“œ Installing mkcert CA root certificate into Windows Trust Store..." -ForegroundColor Cyan + Import-Certificate -FilePath $tempCert -CertStoreLocation Cert:\LocalMachine\Root + Remove-Item $tempCert + Write-Host "โœ… CA root certificate installed successfully!" -ForegroundColor Green + Write-Host "" + Write-Host "โš ๏ธ Please RESTART YOUR BROWSER (fully close and reopen) for changes to take effect." -ForegroundColor Yellow + Write-Host "" + Write-Host "Your HTTPS URLs should now work:" -ForegroundColor Cyan + Write-Host " โ€ข https://localhost:8888" + Write-Host " โ€ข https://localhost:3002" + Write-Host " โ€ข https://localhost:8889" +} else { + Write-Host "โŒ Certificate file not found." -ForegroundColor Red + Write-Host "" + Write-Host "๐Ÿ“‹ Manual installation steps:" -ForegroundColor Yellow + Write-Host "1. From the Docker container, copy the certificate:" + Write-Host " docker cp :/workspaces/aesthetic-computer/ssl-dev/rootCA.pem C:\Users\$env:USERNAME\Downloads\rootCA.pem" + Write-Host "" + Write-Host "2. Then run this command:" + Write-Host " Import-Certificate -FilePath C:\Users\$env:USERNAME\Downloads\rootCA.pem -CertStoreLocation Cert:\LocalMachine\Root" + Write-Host "" + Write-Host "3. Restart your browser" +}