diff --git a/scp.js b/scp.js index 592ca67..af8de5f 100644 --- a/scp.js +++ b/scp.js @@ -15,9 +15,17 @@ scp.send = function (options, cb) { '-r', '-P', (options.port == undefined ? '22' : options.port) - options.file, - (options.user == undefined ? '' : options.user+'@') + options.host + ':' + options.path, ]; + if (options.identityFile) { + command.push('-i', options.identityFile); + } + if (options.batchMode) { + command.push('-B'); + } + command.push( + options.file, + (options.user == undefined ? '' : options.user+'@') + options.host + ':' + options.path + ); exec(command.join(' '), function (err, stdout, stderr) { if (cb) { cb(err, stdout, stderr); @@ -33,10 +41,18 @@ scp.send = function (options, cb) { scp.get = function (options, cb) { var command = [ 'scp', - '-r', + '-r' + ]; + if (options.identityFile) { + command.push('-i', options.identityFile); + } + if (options.batchMode) { + command.push('-B'); + } + command.push( (options.user == undefined ? '' : options.user+'@') + options.host + ':' + options.file, options.path - ]; + ); exec(command.join(' '), function (err, stdout, stderr) { if (cb) { cb(err, stdout, stderr);