diff --git a/README.md b/README.md index e92390b..b604896 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,9 @@ proper briefing you can't do remote flights which require at least one destination. Each destination consists of one ore more hosts. Values in the hosts section are passed directly to the `connect()` -method of [mscdex/ssh2](https://github.com/mscdex/ssh2#connection-methods). +method of [mscdex/ssh2](https://github.com/mscdex/ssh2#connection-methods) +with one exception: `privateKey` needs to be passed as a string +containing the path to the keyfile instead of the key itself. ```javascript plan.briefing({ diff --git a/lib/flightplan.js b/lib/flightplan.js index d1b49fc..2083192 100644 --- a/lib/flightplan.js +++ b/lib/flightplan.js @@ -103,7 +103,9 @@ Flightplan.prototype = { * least one destination. Each destination consists of one ore more hosts. * * Values in the hosts section are passed directly to the `connect()` - * method of [mscdex/ssh2](https://github.com/mscdex/ssh2#connection-methods). + * method of [mscdex/ssh2](https://github.com/mscdex/ssh2#connection-methods) + * with one exception: `privateKey` needs to be passed as a string + * containing the path to the keyfile instead of the key itself. * * ```javascript * plan.briefing({ diff --git a/lib/transport/shell.js b/lib/transport/shell.js index cc152f6..2e8e8b3 100644 --- a/lib/transport/shell.js +++ b/lib/transport/shell.js @@ -83,8 +83,10 @@ ShellTransport.prototype.__transfer = function(files, remoteDir, options) { var future = new Future(); Fiber(function() { - var cmd = util.format('(echo "%s") | rsync --files-from - %s --rsh="ssh -p%s" ./ %s@%s:%s' - , files, rsyncFlags, config.port || 22, config.username, config.host, remoteDir); + var sshFlags = (config.privateKey ? ' -i ' + config.privateKey : ''); + var cmd = util.format('(echo "%s") | rsync --files-from - %s --rsh="ssh -p%s%s" ./ %s@%s:%s' + , files, rsyncFlags, config.port || 22, sshFlags + , config.username, config.host, remoteDir); _results.push(this.exec(cmd, options)); return future.return(); }.bind(this)).run(); diff --git a/lib/transport/ssh.js b/lib/transport/ssh.js index 40ed1c6..7dde1aa 100644 --- a/lib/transport/ssh.js +++ b/lib/transport/ssh.js @@ -1,4 +1,5 @@ var util = require('util') + , fs = require('fs') , Fiber = require('fibers') , Connection = require('ssh2') , Transport = require('./transport'); @@ -18,7 +19,10 @@ function SSHTransport(flight, target) { var options = util._extend({}, this.target); // clone delete options.exec; - this.connection.connect(this.target); + if(options.privateKey) { + options.privateKey = fs.readFileSync(options.privateKey, { encoding: 'utf8' }); + } + this.connection.connect(options); return Fiber.yield(); } diff --git a/package.json b/package.json index a0da877..8deb6a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "flightplan", "description": "Library for streamlining application deployment or systems administration tasks", - "version": "0.1.8", + "version": "0.1.9", "author": "Patrick Stadler ", "keywords": [ "deploy",