im learning jenkins for the moment and i had a problem with sshagent . i can't connect to my remote machine .
first i'm trying to deploy into kubernetes using jenkins .and i'm using ssh agent to get into kubernetes-master so i can run command from it .
so the probleme is i genareted a ssh key in my kubernetes-master and i added the private key to jenkins but it not working .
any help here plz
here you find the stage .of deployment in the pipeline
and the output console when i executed the job
jenkins output console
stage('deploy to K8s cluster '){
steps{
sshagent(['Jenkins-Access-Kube']) {
sh"scp -r -o StrictHostKeyChecking=no /home/automate-deployment-on-k8s/complete-demo.yaml younes@192.168.8.199:/home/younes/k8s"
script{
try{
sh 'ssh younes@192.168.8.199 kubectl apply -f . '
}catch(error){
sh 'ssh younes@192.168.8.199 kubectl create -f . '
}
}
}