server->ipv4 ?? $this->server->ipv6) ->usePassword($this->rootPassword) ->disableStrictHostKeyChecking() ->setTimeout(10) ->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()); logger('output'); logger($process->getOutput()); logger($process->getErrorOutput()); $this->release(15); return; } $this->server->update([ 'status' => ServerStatus::UNPROVISIONED, ]); dispatch(new ProvisionServer($this->server, $this->rootPassword, $this->sudoPassword)); } public function failed(\Throwable $exception): void { $this->server->update([ 'status' => ServerStatus::PROVIDER_TIMEOUT, ]); } }