Skip to content

Commit

Permalink
Transport#transfer() now uses the privateKey path defined in briefing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pstadler committed Mar 5, 2014
1 parent 8d8b904 commit ce21c79
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion lib/flightplan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 4 additions & 2 deletions lib/transport/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion lib/transport/ssh.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var util = require('util')
, fs = require('fs')
, Fiber = require('fibers')
, Connection = require('ssh2')
, Transport = require('./transport');
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"keywords": [
"deploy",
Expand Down

0 comments on commit ce21c79

Please sign in to comment.