package com.homelab.utilities def create() { withCredentials([file(credentialsId: 'ssh-private-key', variable: 'FILE')]) { sh """ cat ${FILE} > ./id_github_jenkins chmod 600 ./id_github_jenkins # Ensure .ssh directory has correct permissions chmod 700 /root/.ssh # Fix SSH config file permissions if it exists if [ -f /root/.ssh/config ]; then chmod 600 /root/.ssh/config chown root:root /root/.ssh/config fi # Fix existing SSH private key permissions if it exists if [ -f /root/.ssh/id_rsa ]; then chmod 600 /root/.ssh/id_rsa chown root:root /root/.ssh/id_rsa fi # Fix any other SSH key files that might exist find /root/.ssh -type f -name "id_*" -exec chmod 600 {} \\; 2>/dev/null || true """ } }