Trying to deploy to a remote host via ssh. I have already tested the sshkey via same jenkins pipeline using bash commands and it works. echo prints the var values correctly as well. So no clue why auth is failing.
<code>stage('Deploy to Host') {
steps {
sshagent(credentials: ['dev-host-ssh-key']) {
script {
def remote = [:]
remote.name = 'remote-host'
remote.host = "$HOST"
remote.user = "$APP_USER"
remote.allowAnyHosts = true
echo "HOST: ${remote.host}"
echo "BASE_DIR: ${env.BASE_DIR}"
echo "APP_USER: ${remote.user}"
try {
sshPut remote: remote, from: 'scripts/', into: "$BASE_DIR/$APP_USER/"
} catch (Exception e) {
echo "Error during sshPut: ${e.message}"
}
</code>
<code>stage('Deploy to Host') {
steps {
sshagent(credentials: ['dev-host-ssh-key']) {
script {
def remote = [:]
remote.name = 'remote-host'
remote.host = "$HOST"
remote.user = "$APP_USER"
remote.allowAnyHosts = true
echo "HOST: ${remote.host}"
echo "BASE_DIR: ${env.BASE_DIR}"
echo "APP_USER: ${remote.user}"
try {
sshPut remote: remote, from: 'scripts/', into: "$BASE_DIR/$APP_USER/"
} catch (Exception e) {
echo "Error during sshPut: ${e.message}"
}
</code>
stage('Deploy to Host') {
steps {
sshagent(credentials: ['dev-host-ssh-key']) {
script {
def remote = [:]
remote.name = 'remote-host'
remote.host = "$HOST"
remote.user = "$APP_USER"
remote.allowAnyHosts = true
echo "HOST: ${remote.host}"
echo "BASE_DIR: ${env.BASE_DIR}"
echo "APP_USER: ${remote.user}"
try {
sshPut remote: remote, from: 'scripts/', into: "$BASE_DIR/$APP_USER/"
} catch (Exception e) {
echo "Error during sshPut: ${e.message}"
}
Error message as caught by try/catch.please exchuse as I had no option but to add the long log as html code.
<code>17:00:24 Identity added: /var/org/jenkins/b12adfb/workspace/3536173/some-dir@tmp/private_key_94848422121.key
17:00:24 [ssh-agent] Started.
17:00:24 [Pipeline] {
17:00:24 [Pipeline] script
17:00:24 [Pipeline] {
17:00:24 [Pipeline] echo
17:00:24 HOST: correct_host_echoed
17:00:24 [Pipeline] echo
17:00:24 BASE_DIR: correct_dir_echoed
17:00:24 [Pipeline] echo
17:00:24 APP_USER: correct_user_echoed
17:00:24 [Pipeline] sshPut
17:00:25 [Pipeline] echo
17:00:25 Error during sshPut: Auth fail
17:00:25 [Pipeline] sshCommand
17:00:25 [Pipeline] }
17:00:25 [Pipeline] // script
17:00:25 [Pipeline] }
17:00:25 $ ssh-agent -k
17:00:25 unset SSH_AUTH_SOCK;
17:00:25 unset SSH_AGENT_PID;
17:00:25 echo Agent pid 1471169 killed;
17:00:25 [ssh-agent] Stopped.
17:00:25 [Pipeline] // sshagent
17:00:25 [Pipeline] }
17:00:25 [Pipeline] // stage
17:00:25 [Pipeline] stage
17:00:25 [Pipeline] { (Declarative: Post Actions)
17:00:25 [Pipeline] cleanWs
17:00:25 [WS-CLEANUP] Deleting project workspace...
17:00:25 [WS-CLEANUP] Deferred wipeout is used...
17:00:25 [WS-CLEANUP] done
17:00:25 [Pipeline] End of Pipeline
17:00:25 Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Podman-p1139181
17:00:25 at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)
17:00:25 at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
17:00:25 at hudson.remoting.Channel.call(Channel.java:1000)
17:00:25 at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:72)
17:00:25 at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution.lambda$start$0(SSHStepExecution.java:84)
17:00:25 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
17:00:25 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
17:00:25 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
17:00:25 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
17:00:25 at java.base/java.lang.Thread.run(Thread.java:834)
17:00:25 com.jcraft.jsch.JSchException: Auth fail</code>
<code>17:00:24 Identity added: /var/org/jenkins/b12adfb/workspace/3536173/some-dir@tmp/private_key_94848422121.key
17:00:24 [ssh-agent] Started.
17:00:24 [Pipeline] {
17:00:24 [Pipeline] script
17:00:24 [Pipeline] {
17:00:24 [Pipeline] echo
17:00:24 HOST: correct_host_echoed
17:00:24 [Pipeline] echo
17:00:24 BASE_DIR: correct_dir_echoed
17:00:24 [Pipeline] echo
17:00:24 APP_USER: correct_user_echoed
17:00:24 [Pipeline] sshPut
17:00:25 [Pipeline] echo
17:00:25 Error during sshPut: Auth fail
17:00:25 [Pipeline] sshCommand
17:00:25 [Pipeline] }
17:00:25 [Pipeline] // script
17:00:25 [Pipeline] }
17:00:25 $ ssh-agent -k
17:00:25 unset SSH_AUTH_SOCK;
17:00:25 unset SSH_AGENT_PID;
17:00:25 echo Agent pid 1471169 killed;
17:00:25 [ssh-agent] Stopped.
17:00:25 [Pipeline] // sshagent
17:00:25 [Pipeline] }
17:00:25 [Pipeline] // stage
17:00:25 [Pipeline] stage
17:00:25 [Pipeline] { (Declarative: Post Actions)
17:00:25 [Pipeline] cleanWs
17:00:25 [WS-CLEANUP] Deleting project workspace...
17:00:25 [WS-CLEANUP] Deferred wipeout is used...
17:00:25 [WS-CLEANUP] done
17:00:25 [Pipeline] End of Pipeline
17:00:25 Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Podman-p1139181
17:00:25 at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)
17:00:25 at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
17:00:25 at hudson.remoting.Channel.call(Channel.java:1000)
17:00:25 at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:72)
17:00:25 at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution.lambda$start$0(SSHStepExecution.java:84)
17:00:25 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
17:00:25 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
17:00:25 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
17:00:25 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
17:00:25 at java.base/java.lang.Thread.run(Thread.java:834)
17:00:25 com.jcraft.jsch.JSchException: Auth fail</code>
17:00:24 Identity added: /var/org/jenkins/b12adfb/workspace/3536173/some-dir@tmp/private_key_94848422121.key
17:00:24 [ssh-agent] Started.
17:00:24 [Pipeline] {
17:00:24 [Pipeline] script
17:00:24 [Pipeline] {
17:00:24 [Pipeline] echo
17:00:24 HOST: correct_host_echoed
17:00:24 [Pipeline] echo
17:00:24 BASE_DIR: correct_dir_echoed
17:00:24 [Pipeline] echo
17:00:24 APP_USER: correct_user_echoed
17:00:24 [Pipeline] sshPut
17:00:25 [Pipeline] echo
17:00:25 Error during sshPut: Auth fail
17:00:25 [Pipeline] sshCommand
17:00:25 [Pipeline] }
17:00:25 [Pipeline] // script
17:00:25 [Pipeline] }
17:00:25 $ ssh-agent -k
17:00:25 unset SSH_AUTH_SOCK;
17:00:25 unset SSH_AGENT_PID;
17:00:25 echo Agent pid 1471169 killed;
17:00:25 [ssh-agent] Stopped.
17:00:25 [Pipeline] // sshagent
17:00:25 [Pipeline] }
17:00:25 [Pipeline] // stage
17:00:25 [Pipeline] stage
17:00:25 [Pipeline] { (Declarative: Post Actions)
17:00:25 [Pipeline] cleanWs
17:00:25 [WS-CLEANUP] Deleting project workspace...
17:00:25 [WS-CLEANUP] Deferred wipeout is used...
17:00:25 [WS-CLEANUP] done
17:00:25 [Pipeline] End of Pipeline
17:00:25 Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Podman-p1139181
17:00:25 at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)
17:00:25 at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
17:00:25 at hudson.remoting.Channel.call(Channel.java:1000)
17:00:25 at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:72)
17:00:25 at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution.lambda$start$0(SSHStepExecution.java:84)
17:00:25 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
17:00:25 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
17:00:25 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
17:00:25 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
17:00:25 at java.base/java.lang.Thread.run(Thread.java:834)
17:00:25 com.jcraft.jsch.JSchException: Auth fail