warn('Keys already exist. Aborting.'); return 1; } $this->info("Generating RSA key pair..."); // Generate 2048-bit RSA private key $res = openssl_pkey_new([ 'private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA, ]); openssl_pkey_export($res, $privateKey); file_put_contents($privatePath, $privateKey); chmod($privatePath, 0600); $pubKeyDetails = openssl_pkey_get_details($res); file_put_contents($publicPath, $pubKeyDetails['key']); chmod($publicPath, 0644); $this->info("✅ Keys generated:"); $this->line("- Private: $privatePath"); $this->line("- Public : $publicPath"); return 0; } }