fix(keys): generate 4096-bit RSA keys

GitHub rejects new RSA SSH keys smaller than 3072 bits, and phpseclib
made 2048-bit keys by default, so new RSA deploy keys from Coolify
could not authenticate.

Closes #12461

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-11-05 11:26:31 +01:00
co-authored by Claude Opus 5.5
parent 51a7e97619
commit 4bdf03db69
2 changed files with 19 additions and 1 deletions
+4 -1
View File
@@ -743,10 +743,13 @@ function generate_random_name(?string $cuid = null): string
return Str::kebab("{$generator->getName()}-$cuid");
}
/**
* RSA keys get 4096 bits: GitHub rejects new RSA SSH keys smaller than 3072 bits, and phpseclib makes 2048-bit keys by default.
*/
function generateSSHKey(string $type = 'rsa')
{
if ($type === 'rsa') {
$key = RSA::createKey();
$key = RSA::createKey(4096);
return [
'private' => $key->toString('PKCS1'),
+15
View File
@@ -0,0 +1,15 @@
<?php
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Crypt\RSA;
it('generates RSA keys that GitHub accepts (at least 3072 bits)', function () {
$keyPair = generateSSHKey('rsa');
$privateKey = PublicKeyLoader::load($keyPair['private']);
$publicKey = PublicKeyLoader::load($keyPair['public']);
expect($privateKey)->toBeInstanceOf(RSA\PrivateKey::class)
->and($privateKey->getLength())->toBeGreaterThanOrEqual(3072)
->and($publicKey->getLength())->toBe($privateKey->getLength());
});