Created
August 18, 2016 09:44
-
-
Save dziamid/530c68e0c71fad77101a6107b27f25de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ssh = require('ssh2'); | |
var Promise = require('bluebird'); | |
var sshConnection = new ssh.Client(); | |
sshConnection.connect({ | |
host: config['QN_Address'], | |
port: 22, | |
username: 'ec2-user', | |
privateKey: require('fs').readFileSync(config['QN_Key']) | |
}); | |
function getConnection() { | |
return new Promise((resolve, reject) => { | |
sshConnection | |
.once('ready', function () { | |
resolve(sshConnection); | |
}) | |
.once('end', function () { | |
reject(); | |
}) | |
.once('error', function (error) { | |
reject(error); | |
}); | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment