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.

Feat: Add ssh key fingerprint and generate one for existing keys

peaklabs-dev1c78067386c4
diff --git a/database/migrations/2024_09_17_111226_add_ssh_key_fingerprint_to_private_keys_table.php b/database/migrations/2024_09_17_111226_add_ssh_key_fingerprint_to_private_keys_table.php
new file mode 100644
index 0000000000..15f56c76b5
--- /dev/null
+++ b/database/migrations/2024_09_17_111226_add_ssh_key_fingerprint_to_private_keys_table.php
@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Models\PrivateKey;
+
+class AddSshKeyFingerprintToPrivateKeysTable extends Migration
+{
+ public function up()
+ {
+ Schema::table('private_keys', function (Blueprint $table) {
+ $table->string('fingerprint')->after('private_key')->unique();
+ });
+
+ PrivateKey::whereNull('fingerprint')->each(function ($key) {
+ $fingerprint = PrivateKey::generateFingerprint($key->private_key);
+ if ($fingerprint) {
+ $key->fingerprint = $fingerprint;
+ $key->save();
+ }
+ });
+ }
+
+ public function down()
+ {
+ Schema::table('private_keys', function (Blueprint $table) {
+ $table->dropColumn('fingerprint');
+ });
+ }
+}