diff --git a/.gitignore b/.gitignore index 82687ac..d4a2f72 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,9 @@ db.sqlite data/settings.db +# ssh keys (sensitive) +data/ssh-keys/ + # next.js /.next/ /out/ diff --git a/src/app/_components/HelpModal.tsx b/src/app/_components/HelpModal.tsx index 1cad0ac..2a90531 100644 --- a/src/app/_components/HelpModal.tsx +++ b/src/app/_components/HelpModal.tsx @@ -55,8 +55,15 @@ export function HelpModal({ isOpen, onClose, initialSection = 'server-settings' +
+
SSH Key Features:
+ +
diff --git a/src/app/_components/PublicKeyModal.tsx b/src/app/_components/PublicKeyModal.tsx new file mode 100644 index 0000000..ac6d461 --- /dev/null +++ b/src/app/_components/PublicKeyModal.tsx @@ -0,0 +1,147 @@ +'use client'; + +import { useState } from 'react'; +import { X, Copy, Check, Server, Globe } from 'lucide-react'; +import { Button } from './ui/button'; + +interface PublicKeyModalProps { + isOpen: boolean; + onClose: () => void; + publicKey: string; + serverName: string; + serverIp: string; +} + +export function PublicKeyModal({ isOpen, onClose, publicKey, serverName, serverIp }: PublicKeyModalProps) { + const [copied, setCopied] = useState(false); + + if (!isOpen) return null; + + const handleCopy = async () => { + try { + // Try modern clipboard API first + if (navigator.clipboard && window.isSecureContext) { + await navigator.clipboard.writeText(publicKey); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } else { + // Fallback for older browsers or non-HTTPS + const textArea = document.createElement('textarea'); + textArea.value = publicKey; + textArea.style.position = 'fixed'; + textArea.style.left = '-999999px'; + textArea.style.top = '-999999px'; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + try { + document.execCommand('copy'); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } catch (fallbackError) { + console.error('Fallback copy failed:', fallbackError); + // If all else fails, show the key in an alert + alert('Please manually copy this key:\n\n' + publicKey); + } + + document.body.removeChild(textArea); + } + } catch (error) { + console.error('Failed to copy to clipboard:', error); + // Fallback: show the key in an alert + alert('Please manually copy this key:\n\n' + publicKey); + } + }; + + return ( +
+
+ {/* Header */} +
+
+
+ +
+
+

SSH Public Key

+

Add this key to your server's authorized_keys

+
+
+ +
+ + {/* Content */} +
+ {/* Server Info */} +
+
+ + {serverName} +
+
+ + {serverIp} +
+
+ + {/* Instructions */} +
+

Instructions:

+
    +
  1. Copy the public key below
  2. +
  3. SSH into your server: ssh root@{serverIp}
  4. +
  5. Add the key to authorized_keys: echo "<paste-key>" >> ~/.ssh/authorized_keys
  6. +
  7. Set proper permissions: chmod 600 ~/.ssh/authorized_keys
  8. +
+
+ + {/* Public Key */} +
+
+ + +
+