Our goal is to send files from jenkins server placed in openshift to another external server. We have configured credentials in jenkins using the SSH username and password (private key). But still we are facing an error related to permission denied. But when we tried to login using the terminal of Jenkins server can reach to IAAS server. The issue only occurs when we are trying in jenkins job. Also, the tips from other site to allow “Passwordauthentication yes” has been set in /etc/ssh/sshd_config
Now are you using a private key or a password. Both is not possible.
How are you running the commands? From the error message it seems that it expects a password entered via a tty device but in Jenkins there is no such thing.
When you really have username with private key you might want to wrap things with ssh-agent or you use the ssh-steps plugin to transfer your files
I am using the ssh agent, but I am suspecting the user of the jenkins workspace,
#!/usr/bin/env groovy
pipeline {
agent any
stages {
stage(“pull xml”){
steps{
checkout scmGit(branches: [[name: ‘*/main’]], extensions: , userRemoteConfigs: [[credentialsId: ‘xxx-token’, url: ‘https://gitlab-ce-xxxx.com/nhk-develop/tool_script_biz.git’]])
}
}
stage(“sftp xml”){
steps{
dir(“./tool_script_biz/A/HSSA001R0/SOAP_UI/UT/”){
sshagent([‘sftpjenkins_test’]){
sh ‘’’
set -x
sftp -oPort="20022" -vvv sftpjenkins@161.xxx.xxx.x <<EOF
put HSSA001R0-soapui-project.xml
bye
EOF
set +x
'''
}
}
}
}
}
}
I have posted the pipeline. the ssh agent has been used.