send the .pub separately
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
This commit is contained in:
parent
76bb0ad258
commit
616f560e7b
@ -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} <serviceaccount.sh
|
||||
|
@ -12,10 +12,10 @@ function restofscript(){
|
||||
cd /home/${USERNAMETOADD}
|
||||
mkdir .ssh
|
||||
pushd .ssh
|
||||
pwd
|
||||
echo ${PUBKEYCONTENT} >> 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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user