title: -bash: ./deploy.sh: Permission denied , ERROR: script returned exit code 126
body: <p>I am trying to implement continuous deployment using Jenkins and that involves sending a jar file to a remote server and start the jar once its on the remote server. </p>
  
  <blockquote>
    <p>The problem is that i keep getting access denied error and i have tried every account i have on my remote and local server nothing seems to work. I get the same Error.</p>
  </blockquote>
  
  <p><strong>Jenkins file</strong></p>
  
  <pre><code>pipeline {
      agent any
  
      stages {
  
          stage ('Packaging stage') {
  
              steps {
                  withMaven(maven : 'Maven') {
                      sh 'mvn clean install'
                  }
              }
          }
  
          stage ('Deploy To Dev Server') {
  
               steps {
                  sh './deploy.sh'
           }
         }
      }
  
  }
  </code></pre>
  
  <p><strong>deploy.sh</strong></p>
  
  <pre><code>#!/usr/bin/expect -f
  spawn scp -P 10022 /var/lib/jenkins/.m2/repository/org/hector/eureka-naming-server/0.0.1-SNAPSHOT/eureka-naming-server-0.0.1-SNAPSHOT.jar
  myUserName@myRemoteServer.net:/home/myname/repository/eureka-service-deploy
  
  expect "password: "
  
  send "myPassword\r"
  
  expect "$ "
  send "other_command_to_execute_on_remote\r"
  expect "$ "
  send "exit\r"
  echo "Successfully sent file"
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ahKbL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ahKbL.png" alt="enter image description here"></a></p>