Files
ladill-hosting/app/Services/Infrastructure/ContaboInfrastructureSshKeyService.php
isaaccladandCursor e251a4cf60
Deploy Ladill Hosting / deploy (push) Failing after 17s
Initial Ladill Hosting app with Gitea deploy pipeline.
Shared web hosting extracted from the platform monolith, with CI deploy
to /var/www/ladill-hosting matching Bird/Domains/Email.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 16:24:20 +00:00

35 lines
886 B
PHP

<?php
namespace App\Services\Infrastructure;
class ContaboInfrastructureSshKeyService
{
/**
* @return array{public_key: string, private_key: string}
*/
public function generate(): array
{
$resource = openssl_pkey_new([
'private_key_bits' => 4096,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
]);
if ($resource === false) {
throw new \RuntimeException('Failed to generate SSH key pair.');
}
openssl_pkey_export($resource, $privateKey);
$details = openssl_pkey_get_details($resource);
$publicKey = $details['key'] ?? '';
if ($publicKey === '') {
throw new \RuntimeException('Failed to export SSH public key.');
}
return [
'public_key' => trim($publicKey)."\n",
'private_key' => $privateKey,
];
}
}