This commit is contained in:
Saeed Vaziry
2024-10-13 12:33:12 +02:00
parent 386d8e73a7
commit 224e0ac2b0
49 changed files with 3668 additions and 766 deletions

View File

@ -2,7 +2,6 @@
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
@ -17,16 +16,17 @@ public function handle(): void
$privateKeyPath = storage_path('ssh-private.pem');
$publicKeyPath = storage_path('ssh-public.key');
if (File::exists($privateKeyPath) && File::exists($publicKeyPath) && !$this->option('force')) {
if (File::exists($privateKeyPath) && File::exists($publicKeyPath) && ! $this->option('force')) {
$this->error('Keys already exist. Use --force to overwrite.');
return;
}
exec('openssl genpkey -algorithm RSA -out ' . $privateKeyPath);
exec('chmod 600 ' . $privateKeyPath);
exec('ssh-keygen -y -f ' . $privateKeyPath . ' > ' . $publicKeyPath);
exec('chown -R ' . get_current_user() . ':' . get_current_user() . ' ' . $privateKeyPath);
exec('chown -R ' . get_current_user() . ':' . get_current_user() . ' ' . $publicKeyPath);
exec('openssl genpkey -algorithm RSA -out '.$privateKeyPath);
exec('chmod 600 '.$privateKeyPath);
exec('ssh-keygen -y -f '.$privateKeyPath.' > '.$publicKeyPath);
exec('chown -R '.get_current_user().':'.get_current_user().' '.$privateKeyPath);
exec('chown -R '.get_current_user().':'.get_current_user().' '.$publicKeyPath);
$this->info('Keys generated successfully.');
}