Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/jobs/install-os.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function installOsJobFactory(
var rootUser = {
name: 'root',
password: this.options.rootPassword,
privateKey: this.options.rootSshKey
publicKey: this.options.rootSshKey
};
this.context.users = _.compact((this.context.users || []).concat(rootUser));
}
Expand Down
9 changes: 6 additions & 3 deletions lib/jobs/sftp-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,19 @@ function sftpJobFactory(
}
});

ssh.connect({
var sshConfig = {
host: sshSettings.host,
port: sshSettings.port || 22,
username: sshSettings.user,
password: cryptService.decrypt(sshSettings.password),
privateKey: cryptService.decrypt(sshSettings.privateKey),
keepaliveInterval: self.keepaliveInterval || 0, //disabled by default
keepaliveCountMax: self.keepaliveCountMax || 3,
readyTimeout: self.timeout || 20000
});
};
if (sshSettings.privateKey) {
sshConfig.privateKey = cryptService.decrypt(sshSettings.privateKey);
}
ssh.connect(sshConfig);
});
};
return SftpJob;
Expand Down
8 changes: 7 additions & 1 deletion lib/jobs/validate-ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ function validationJobFactory(
if (sshSettings.password !== null && sshSettings.password !== undefined) {
config.password = encryption.encrypt(sshSettings.password);
}
if (sshSettings.publicKey !== null && sshSettings.publicKey !== undefined) {
config.publicKey = encryption.encrypt(sshSettings.publicKey);
}
if (sshSettings.privateKey !== null && sshSettings.privateKey !== undefined) {
config.privateKey = encryption.encrypt(sshSettings.privateKey);
}
Expand Down Expand Up @@ -118,14 +121,17 @@ function validationJobFactory(
host: addr,
user: credentials.name,
password: credentials.password,
privateKey: credentials.sshKey,
tryKeyboard: true
};
if (credentials.privateKey) {
sshSettings.privateKey = credentials.privateKey;
}
conn.on('ready', function() {
conn.end();
if(sshSettings.host === null){
reject('host ip is not defined in this lookup.');
}
sshSettings.publicKey = credentials.sshKey;
resolve(sshSettings);
})
.on('keyboard-interactive', function() {
Expand Down
9 changes: 6 additions & 3 deletions lib/utils/job-utils/command-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,17 @@ function commandUtilFactory(
resolve(cmdObj);
}
});
ssh.connect({
var sshConfig = {
host: sshSettings.host,
port: sshSettings.port || 22,
username: sshSettings.user || sshSettings.username,
password: cryptService.decrypt(sshSettings.password),
privateKey: cryptService.decrypt(sshSettings.privateKey),
tryKeyboard: true
});
};
if (sshSettings.privateKey) {
sshConfig.privateKey = cryptService.decrypt(sshSettings.privateKey);
}
ssh.connect(sshConfig);
});
};

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/jobs/install-os-job-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('Install OS Job', function () {

it('should provide the given user credentials to the context', function() {
expect(job.context.users).to.deep.equal(
job.options.users.concat({name: 'root', password: 'rackhd', privateKey: 'testkey'})
job.options.users.concat({name: 'root', password: 'rackhd', publicKey: 'testkey'})
);
});

Expand Down
8 changes: 6 additions & 2 deletions spec/lib/jobs/validate-ssh-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ describe('Validate Ssh', function() {
sshSettings = {
username: 'a username',
password: 'a password',
privateKey: 'a pretty long string'
publicKey: 'a pretty long, publicKey string',
privateKey: 'a pretty long, privateKey string'
};
users = [
{name: 'someUser', password: 'somePassword'},
Expand Down Expand Up @@ -81,10 +82,13 @@ describe('Validate Ssh', function() {
expect(settings).to.have.property('user').that.equals(sshSettings.username);
expect(settings).to.have.property('password')
.that.not.equal(sshSettings.password);
expect(settings).to.have.property('publicKey')
.that.not.equal(sshSettings.publicKey);
expect(settings).to.have.property('privateKey')
.that.not.equal(sshSettings.privateKey);

expect(encryption.decrypt(settings.password)).to.equal(sshSettings.password);
expect(encryption.decrypt(settings.publicKey)).to.equal(sshSettings.publicKey);
expect(encryption.decrypt(settings.privateKey)).to.equal(sshSettings.privateKey);
});
});
Expand Down Expand Up @@ -139,7 +143,7 @@ describe('Validate Ssh', function() {
host: '1.2.3.4',
user:'user',
password: 'pass',
privateKey: 'key',
publicKey: 'key',
tryKeyboard: true
});
});
Expand Down