mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(install): keep operator SSH keys that mention coolify
On a fresh install, install.sh removed every authorized_keys line that contained "coolify", including unrelated operator keys such as one commented "coolify-disposable". Remove only lines whose comment is exactly "coolify", the comment of the installer's own key. Closes #12278 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
da462c9f9a
commit
54c930d8dd
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
it('removes only the previous Coolify key from authorized_keys', function (string $path) {
|
||||
$script = file_get_contents(dirname(__DIR__, 2).'/'.$path);
|
||||
preg_match('/^\s*(sed -i .*~\/\.ssh\/authorized_keys)$/m', $script, $matches);
|
||||
expect($matches)->toHaveKey(1);
|
||||
|
||||
$home = sys_get_temp_dir().'/coolify-install-keys-'.bin2hex(random_bytes(4));
|
||||
mkdir($home.'/.ssh', 0700, true);
|
||||
file_put_contents($home.'/.ssh/authorized_keys', implode("\n", [
|
||||
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-disposable',
|
||||
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey operator-lab',
|
||||
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHostKey root@coolify',
|
||||
'no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOptions deploy@coolify.example.com',
|
||||
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOldCoolifyKey coolify',
|
||||
'',
|
||||
]));
|
||||
|
||||
$process = new Process(['bash', '-c', $matches[1]], null, ['HOME' => $home]);
|
||||
$process->mustRun();
|
||||
|
||||
expect(file_get_contents($home.'/.ssh/authorized_keys'))->toBe(implode("\n", [
|
||||
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-disposable',
|
||||
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey operator-lab',
|
||||
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHostKey root@coolify',
|
||||
'no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOptions deploy@coolify.example.com',
|
||||
'',
|
||||
]));
|
||||
|
||||
exec('rm -rf '.escapeshellarg($home));
|
||||
})->with([
|
||||
'stable install script' => ['scripts/install.sh'],
|
||||
'nightly install script' => ['other/nightly/install.sh'],
|
||||
]);
|
||||
Reference in New Issue
Block a user