Skip to content
This repository was archived by the owner on Mar 18, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ Type: `Boolean`

Perform a shallow clone. Default: `false`.

#### strictHost

Type: `String`

Sets the option to enable or disable StrictHostKeyChecking for the SSH connection.


### Usage example

```js
Expand All @@ -118,7 +125,8 @@ shipit: {
ignores: ['.git', 'node_modules'],
keepReleases: 2,
key: '/path/to/key',
shallowClone: true
shallowClone: true,
strictHost: 'no'
},
staging: {
servers: '[email protected]'
Expand Down
3 changes: 3 additions & 0 deletions lib/ssh/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,8 @@ function buildSSHArgs(options) {
if (options.key) {
args.push('-i ' + options.key);
}
if(options.strictHost) {
args.push('-o StrictHostKeyChecking=' + options.strictHost);
}
return args;
}
23 changes: 23 additions & 0 deletions test/unit/ssh/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ describe('SSH Connection', function () {
'ssh -p 12345 -i /path/to/key user@host "my-command -x"'
);
});

it('should use StrictHostKeyChecking if present', function () {
connection = new Connection({
remote: 'user@host',
logger: logger,
strictHost: 'no'
});
connection.run('my-command -x', function () {});
expect(childProcess.exec).to.be.calledWith(
'ssh -o StrictHostKeyChecking=no user@host "my-command -x"'
);
});
});

describe('#copy', function () {
Expand Down Expand Up @@ -193,6 +205,17 @@ describe('SSH Connection', function () {
connection.copy('/src/dir', '/dest/dir', done);
expect(childProcess.exec).to.be.calledWith('rsync -az -e "ssh -p 12345 -i /path/to/key" /src/dir user@host:/dest/dir');
});

it('should use StrictHostKeyChecking if present', function (done) {
connection = new Connection({
remote: 'user@host',
logger: logger,
strictHost: 'yes'
});
connection.copy('/src/dir', '/dest/dir', done);
expect(childProcess.exec).to.be.calledWith('rsync -az -e "ssh -o StrictHostKeyChecking=yes" /src/dir user@host:/dest/dir');
});


});
});