Ensure .ssh directory exists before creating SSH identity file

This commit is contained in:
Bastian (BaM)
2025-09-14 12:45:44 +02:00
parent 17125b6600
commit 09b4acd110

View File

@@ -82,6 +82,12 @@ local function createSSHKeyFilesFromEnv()
return
end
-- Ensure .ssh directory exists
local ssh_dir = SSH_IDENTITY_FILE:match("^(.*)/[^/]+$
if ssh_dir then
os.execute(("mkdir -p %q && chmod 700 %q"):format(ssh_dir, ssh_dir))
end
local priv_fh = io.open(SSH_IDENTITY_FILE, "w")
if not priv_fh then
log("Failed to open SSH identity file for writing: " .. SSH_IDENTITY_FILE)