This commit is contained in:
2025-04-07 12:16:11 +01:00
parent ce8b201a1c
commit e15a80163b
62 changed files with 149 additions and 131 deletions

View File

@@ -8,27 +8,30 @@ use Illuminate\Support\Facades\Process;
class GenerateSshKey extends Command
{
protected $signature = 'setup:generate-ssh-key';
protected $description = 'Generates an SSH key pair for the application.';
public function handle()
{
if (file_exists(storage_path('app/private/ssh/id_ed25519'))) {
$this->components->info('SSH key pair already exists.');
return;
}
$this->components->info('Generating SSH key pair...');
if (!file_exists(storage_path('app/private/ssh'))) {
if (! file_exists(storage_path('app/private/ssh'))) {
$this->components->info('ssh directory does not exist. Creating it now...');
mkdir(storage_path('app/private/ssh'), 0755, true);
}
$result = Process::run(['ssh-keygen', '-t', 'ed25519', '-f', storage_path('app/private/ssh/id_ed25519'), '-N', '']);
if (!$result->successful()) {
if (! $result->successful()) {
$this->components->error('Failed to generate SSH key pair.');
$this->line($result->output());
$this->line($result->errorOutput());
return;
}