From 3471cf1819bb7a6518e696b89474d8793524bd5e Mon Sep 17 00:00:00 2001 From: "Harry (hjbdev)" Date: Sun, 30 Mar 2025 14:03:52 +0000 Subject: [PATCH] cloudinit fix for password expiry --- .../Requests/Hetzner/Servers/CreateServerRequest.php | 1 + app/Jobs/Servers/WaitForServerToConnect.php | 10 ---------- resources/scripts/hetzner-cloudinit.yml | 3 +++ 3 files changed, 4 insertions(+), 10 deletions(-) create mode 100644 resources/scripts/hetzner-cloudinit.yml diff --git a/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php b/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php index cdc1f83..00d03b5 100644 --- a/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php +++ b/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php @@ -27,6 +27,7 @@ class CreateServerRequest extends Request implements HasBody 'name' => $this->name, 'server_type' => $this->serverType, 'location' => $this->location, + 'user_data' => file_get_contents(resource_path('scripts/hetzner-cloudinit.yml')), ]; } diff --git a/app/Jobs/Servers/WaitForServerToConnect.php b/app/Jobs/Servers/WaitForServerToConnect.php index a4d4cf5..d6df088 100644 --- a/app/Jobs/Servers/WaitForServerToConnect.php +++ b/app/Jobs/Servers/WaitForServerToConnect.php @@ -34,16 +34,6 @@ 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()); diff --git a/resources/scripts/hetzner-cloudinit.yml b/resources/scripts/hetzner-cloudinit.yml new file mode 100644 index 0000000..f624814 --- /dev/null +++ b/resources/scripts/hetzner-cloudinit.yml @@ -0,0 +1,3 @@ +#cloud-config +chpasswd: + expire: false \ No newline at end of file