serverId = $serverId; } public static function modalMaxWidth(): string { return 'lg'; } /** Generate a fresh ed25519 keypair: the public key is installed on save, * the private key is shown once for the operator to store. */ public function generate(): void { $this->error = null; $key = EC::createKey('ed25519'); $this->publicKey = $key->getPublicKey()->toString('OpenSSH', ['comment' => 'clusev-key']); $this->generatedPrivate = (string) $key->toString('OpenSSH'); } public function save(FleetService $fleet): void { $this->error = null; $server = Server::find($this->serverId); if (! $server) { $this->error = 'Server nicht gefunden.'; return; } try { $fleet->addAuthorizedKey($server, $this->publicKey); } catch (Throwable $e) { $this->error = $e->getMessage(); return; } AuditEvent::create([ 'user_id' => Auth::id(), 'server_id' => $server->id, 'actor' => Auth::user()?->name ?? 'system', 'action' => 'ssh_key.add', 'target' => $server->name, 'ip' => request()->ip(), ]); $this->dispatch('keyChanged'); $this->dispatch('notify', message: 'SSH-Schlüssel hinzugefügt.'); $this->closeModal(); } public function render() { return view('livewire.modals.add-ssh-key'); } }