diff --git a/scripts/1clickservice.groovy b/scripts/1clickservice.groovy index 8bb7b48..9e7bfb8 100644 --- a/scripts/1clickservice.groovy +++ b/scripts/1clickservice.groovy @@ -204,7 +204,7 @@ pipeline { rm cookies.txt pushd ${servicename} - git -c core.sshCommand="ssh -i '$PK'\" push + git -c core.sshCommand="ssh -i '${PK}'\" push """ } } @@ -215,20 +215,18 @@ pipeline { script { withCredentials([sshUserPrivateKey(credentialsId: env.SUDOERSSHID, keyFileVariable: 'PK')]) { + sh 'scp ${servicename}-ssh.pub -i \"${PK}\" ${SUDOER_USR}@${targetHost}:~/ssh.pub' + sh """#!/bin/bash ssh-keyscan -t ed25519 ${targetHost} >> ~/.ssh/known_hosts - cat "${PK}" - + curl -u '${env.GITEA_USR}:${env.GITEATOKEN}' https://gitea.arg.rip/greyn/deployment/raw/branch/service/scripts/serviceaccount.sh --output serviceaccount.sh sed -i 's/USERNAMETOADD=/USERNAMETOADD="${servicename}"/' serviceaccount.sh sed -i 's/PASSWORDTOADD=/PASSWORDTOADD="${env.pw_linuxserviceaccount}"/' serviceaccount.sh - sed -i "s/PUBKEYCONTENT=/PUBKEYCONTENT=\"\$(cat ${servicename}-ssh.pub)"/\" serviceaccount.sh sed -i 's/SUDOER_PSW=/SUDOER_PSW="${SUDOER_PSW}"/' serviceaccount.sh echo "serviceaccount :)" - pwd - ls cat serviceaccount.sh ssh -i \"${PK}\" -tt ${SUDOER_USR}@${targetHost} > authorized_keys - chmod 600 authorized_keys + touch authorized_keys popd + cat ssh.pub >> .ssh/authorized_keys + chmod 600 authorized_keys chown -R "${USERNAMETOADD}:${USERNAMETOADD}" .ssh }