title: How execute multiple commands on SSH2 using NodeJS
body: <p>I'm trying to deploy from GitHub using I want to execute more than one command, in order of the array. The code I'm using now is included below.</p>
  
  <pre><code>async.series([
  ...
  // Deploy from GitHub
  function (callback) {
      // Console shizzle:
      console.log('');
      console.log('Deploying...'.red.bold);
      console.log();
      console.log();
  
      var deployFunctions = [
          {
              command: 'cd ' + envOptions.folder + ' &amp;&amp; pwd',
              log: false
          },
          {
              command: 'pwd'
          },
          {
              command: 'su ' + envOptions.user,
              log: false
          },
          {
              command: 'git pull'
          },
          {
              command: 'chmod 0777 * -R',
              log: false
          }
      ];
      async.eachSeries(deployFunctions, function (item, callback) {
          deployment.ssh2.exec(item.command, function (err, stream) {
              deployment.logExec(item);
              stream.on('data', function (data, extended) {
                  console.log(data.toString().trim());
                  console.log();
              });
              function done() {
                  callback(err);
              }
  
              stream.on('exit', done);
              stream.on('end', done);
          });
      }, function () {
          callback();
      });
  },
  ...);
  </code></pre>
  
  <p>But, after I cd'ed to the right directory, it forgets where it was and starts all over again.</p>
  
  <pre><code>$ cd /some/folder &amp;&amp; pwd
  /some/folder
  
  $ pwd
  /root
  </code></pre>