From 15379acbdc7f9d0e7c2db4fbdeba9d519f58b640 Mon Sep 17 00:00:00 2001 From: "Harry (hjbdev)" Date: Sun, 30 Mar 2025 13:47:19 +0000 Subject: [PATCH] try updating the password --- app/Jobs/Servers/WaitForServerToConnect.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Jobs/Servers/WaitForServerToConnect.php b/app/Jobs/Servers/WaitForServerToConnect.php index 1d5984b..a4d4cf5 100644 --- a/app/Jobs/Servers/WaitForServerToConnect.php +++ b/app/Jobs/Servers/WaitForServerToConnect.php @@ -7,6 +7,7 @@ use App\Models\Server; use Illuminate\Contracts\Queue\ShouldBeEncrypted; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; +use Illuminate\Support\Str; use Spatie\Ssh\Ssh; class WaitForServerToConnect implements ShouldQueue, ShouldBeEncrypted @@ -33,6 +34,16 @@ class WaitForServerToConnect implements ShouldQueue, ShouldBeEncrypted ->execute('echo "Connected"'); if (! $process->isSuccessful()) { + if (str_contains($process->getErrorOutput(), 'Password change required')) { + $newRootPassword = Str::random(24); + Ssh::create('root', $this->server->ipv4 ?? $this->server->ipv6) + ->usePassword($this->rootPassword) + ->execute('echo "root:'.$newRootPassword.'" | chpasswd'); + + $this->rootPassword = $newRootPassword; + $this->release(15); + return; + } logger('root pw: ' . $this->rootPassword); logger('server not reachable'); logger('exit code' . $process->getExitCode());