Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Fix: Make sure in use private keys are not deleted

peaklabs-dev6a6b947fbaea
diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php
index f2fa9c9cf7..fef464823c 100644
--- a/app/Models/PrivateKey.php
+++ b/app/Models/PrivateKey.php
@@ -144,6 +144,10 @@ class PrivateKey extends BaseModel
public static function deleteFromStorage(self $privateKey)
{
+ if ($privateKey->isInUse()) {
+ throw new \Exception('Cannot delete a private key that is in use.');
+ }
+
$filename = "ssh@{$privateKey->uuid}";
Storage::disk('ssh-keys')->delete($filename);
}