import type { Metadata } from "next"; import { Accordion, Label as MuLabel } from "@unlocalhosted/metalui"; import { deleteSshKeyAction } from "@/app/actions/settings"; import { ConfirmButton } from "@/components/confirm-button"; import { KeyIcon } from "@/components/icons"; import { AccordionItem, AccordionPanel, AccordionTrigger, SettingsRow, SettingsSection } from "@/components/metal"; import { CopyIconButton } from "@/components/settings-fields"; import { ListRow, PlateSection, RowGlyph } from "@/components/settings-plate"; import { Alert, Blankslate, Box, Label, PageTitle } from "@/components/ui"; import { requireViewer } from "@/lib/auth"; import { formatDate, timeAgo } from "@/lib/format"; import { listSshKeys } from "@/lib/keys"; import { serverHost } from "@/lib/request-origin"; import { SSH_ENABLED, sshTestCommand } from "@/lib/ssh-config"; import { AddKeyForm } from "./form"; export const metadata: Metadata = { title: "SSH keys" }; export default async function KeysPage() { const viewer = await requireViewer(); const keys = listSshKeys(viewer.id); const test = sshTestCommand(await serverHost()); return (
{!SSH_ENABLED && The SSH server is disabled on this instance (SSH_DISABLED=1).} {keys.length === 0 ? ( } title="No SSH keys yet"> Add a key below to push with git@ URLs. ) : ( {keys.map((key) => ( } title={ <> {key.title} } meta={ <> {key.fingerprint} Added {formatDate(key.createdAt)} ·{" "} {key.lastUsedAt ? ( <> Last used {timeAgo(key.lastUsedAt)} ) : ( "Never used" )} } > Delete Key ))} )} {test}} > Don’t have a key yet?

Generate one and paste the contents of the .pub file:

                  ssh-keygen -t ed25519 -C "{viewer.email}"{"\n"}cat ~/.ssh/id_ed25519.pub
                
); }