title: scp a file to a unix server in node js
body: <p>I'm using the below code to copy a file to a remote unix server, but only the first line of the source file is written to the destination file.</p>
  
  <pre><code>var client = require('scp2');
  var ssh = require('node-sshclient');
  var exec = require('child_process').exec;
  var waitOn = require('wait-on');
  
  module.exports.copy =  function(filename, cb){
  
      client.scp(filename, 'root:hoplehd@10.20.138.185:22:/opt/', function(err) {
          if (err){
              console.log(err);    
          }else{
              console.log("succeeded copying the file to remote server");
          }
      })
  }
  </code></pre>