title: execute commands on remote host in a Jenkinsfile
body: <p>i am trying to ssh into a remote host and then execute certain commands on the remote host's shell. Following is my pipeline code.</p>
  
  <pre><code>pipeline {
      agent any
      environment {
          // comment added
           APPLICATION = 'app'
           ENVIRONMENT = 'dev'
           MAINTAINER_NAME = 'jenkins'
           MAINTAINER_EMAIL = 'jenkins@email.com'
      }
      stages {
           stage('clone repository') {
               steps {
                   // cloning repo
                   checkout scm
               }
           }
           stage('Build Image') {
               steps {
                   script {
                       sshagent(credentials : ['jenkins-pem']) {
                          sh "echo pwd"
                          sh 'ssh -t -t ubuntu@xx.xxx.xx.xx -o StrictHostKeyChecking=no'
                          sh "echo pwd"
                          sh 'sudo -i -u root'
                          sh 'cd /opt/docker/web'
                          sh 'echo pwd'
                      }
                   }
               }
           }
       }
  }
  </code></pre>
  
  <p>But upon running this job it executes <code>sh 'ssh -t -t ubuntu@xx.xxx.xx.xx -o StrictHostKeyChecking=no'</code> successfully but it stops there and does not execute any further commands. I want to execute the commands that are written after <code>ssh</code> command inside the remote host's shell. any help is appreciated. </p>