"use client"; import { useState } from "react"; import { useMutation } from "@tanstack/react-query"; import { api, NewServerResponse } from "@/lib/api"; import { Button, Card, CardHeader, CardTitle } from "@/components/ui"; export default function NewServerPage() { const [result, setResult] = useState(null); const [copied, setCopied] = useState(false); const { mutate: createServer, isPending, error } = useMutation({ mutationFn: api.createServer, onSuccess: (data) => setResult(data), }); const handleCopy = async () => { if (!result?.install_command) return; await navigator.clipboard.writeText(result.install_command); setCopied(true); setTimeout(() => setCopied(false), 2000); }; return (

Add Server

Generate an install command to register a new server with the KeyManager agent.

{!result ? ( Generate Install Command

Click the button below to generate a one-time install command. The command contains a short-lived token (valid for 1 hour) that registers your server and installs the KeyManager agent automatically.

{error && (
Failed to generate install command. Make sure the backend is running.
)}
) : ( <> Install Command Valid for 1 hour

Run this command on the target server as root:

                  ${" "}
                  {result.install_command}
                
Server Details
Server ID
{result.server_id}
Status
Pending registration
What happens next?
    {[ "The install script detects your CPU architecture (amd64 / arm64)", "Downloads and verifies the latest agent binary from the Gitea release", "Writes /etc/keymanager/config.yaml with the server ID and token", "Installs and starts the keymanager-agent systemd service", "The agent calls Register() to obtain a persistent auth token", "The server status changes to active on the first successful sync", ].map((step, i) => (
  1. {i + 1} {step}
  2. ))}
)}
); }