{"record":{"id":"fc72cc122e951350","repo":"coollabsio/coolify","slug":"ssh-key-file-was-not-created-keylocation","errorCode":null,"errorMessage":"SSH key file was not created: {$keyLocation}","messagePattern":"SSH key file was not created: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"app/Models/PrivateKey.php","lineNumber":234,"sourceCode":"        if ($lockHandle === false) {\n            throw new \\Exception(\"Failed to open lock file for SSH key: {$lockFile}\");\n        }\n\n        try {\n            if (! flock($lockHandle, LOCK_EX)) {\n                throw new \\Exception(\"Failed to acquire lock for SSH key: {$keyLocation}\");\n            }\n\n            // Attempt to store the private key\n            $success = $disk->put($filename, $this->private_key);\n\n            if (! $success) {\n                throw new \\Exception(\"Failed to write SSH key to filesystem. Check disk space and permissions for: {$keyLocation}\");\n            }\n\n            // Verify the file was actually created and has content\n            if (! $disk->exists($filename)) {\n                throw new \\Exception(\"SSH key file was not created: {$keyLocation}\");\n            }\n\n            $storedContent = $disk->get($filename);\n            if (empty($storedContent) || $storedContent !== $this->private_key) {\n                $disk->delete($filename); // Clean up the bad file\n                throw new \\Exception(\"SSH key file content verification failed: {$keyLocation}\");\n            }\n\n            // Ensure correct permissions for SSH (0600 required)\n            if (file_exists($keyLocation) && ! chmod($keyLocation, 0600)) {\n                Log::warning('Failed to set SSH key file permissions to 0600', [\n                    'key_uuid' => $this->uuid,\n                    'path' => $keyLocation,\n                ]);\n            }\n\n            return $keyLocation;\n        } finally {","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/coollabsio/coolify/blob/70b9acc42467278373e00de77abb40684e25b395/app/Models/PrivateKey.php#L216-L252","documentation":"Thrown by PrivateKey::storeInFileSystem() (app/Models/PrivateKey.php:234). The disk->put() call reported success, but a follow-up $disk->exists($filename) check cannot find the file. On the local driver this should be impossible unless something deleted the file between put and exists (another worker, antivirus, a misbehaving sync daemon like OneDrive/Dropbox-style tooling on the host path), or the disk root configuration changed between calls.","triggerScenarios":"Storing an SSH key while an external process removes files in /data/coolify/ssh (backup tooling misconfigured to 'clean' the dir, host-side sync software, security scanner), or concurrent key deletions for the same uuid.","commonSituations":"Host cron jobs that sweep 'stale' files from data volumes; dual Coolify instances pointed at the same /data/coolify; aggressive EDR on the host deleting private-key-looking files.","solutions":["Check for external processes touching /data/coolify/ssh on the host (auditd, lsof, cron) and exclude it from cleanup/sync tools.","Ensure only one Coolify instance uses this data directory.","Retry the key save once the external interference is removed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $privateKey->storeInFileSystem();\n} catch (\\Exception $e) {\n    if (str_contains($e->getMessage(), 'was not created')) {\n        // something external removes files from /data/coolify/ssh — audit host processes, then retry\n    }\n    throw $e;\n}","preventionTips":["Exclude /data/coolify/ssh from host cleanup/sync/AV tooling and from any second Coolify instance.","Use host auditing (auditd watches) when files vanish unexpectedly."],"tags":["coolify","ssh-key","file-storage","concurrency","verification"],"backgroundTag":"file-write-verification-failed","analyzedSha":"70b9acc42467278373e00de77abb40684e25b395","analyzedAt":"2026-08-17T01:41:01.313Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}