mirror of
https://github.com/tiennm99/coolify.git
synced 2026-09-04 10:16:46 +00:00
fix(ssh): handle chmod failures gracefully and simplify key management
- Log warnings instead of silently failing when chmod 0600 fails - Remove redundant refresh() call before SSH key validation - Remove storeInFileSystem() call from updatePrivateKey() transaction - Remove @unlink() of lock file after filesystem store - Refactor unit tests to use real temp disk and anonymous class stub instead of reflection-only checks
This commit is contained in:
@@ -209,8 +209,6 @@ class SshMultiplexingHelper
|
||||
|
||||
private static function validateSshKey(PrivateKey $privateKey): void
|
||||
{
|
||||
$privateKey->refresh();
|
||||
|
||||
$keyLocation = $privateKey->getKeyLocation();
|
||||
$filename = "ssh_key@{$privateKey->uuid}";
|
||||
$disk = Storage::disk('ssh-keys');
|
||||
@@ -236,8 +234,11 @@ class SshMultiplexingHelper
|
||||
// Ensure correct permissions (SSH requires 0600)
|
||||
if (file_exists($keyLocation)) {
|
||||
$currentPerms = fileperms($keyLocation) & 0777;
|
||||
if ($currentPerms !== 0600) {
|
||||
chmod($keyLocation, 0600);
|
||||
if ($currentPerms !== 0600 && ! chmod($keyLocation, 0600)) {
|
||||
Log::warning('Failed to set SSH key file permissions to 0600', [
|
||||
'key_uuid' => $privateKey->uuid,
|
||||
'path' => $keyLocation,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user