-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathkeys.js
More file actions
19 lines (19 loc) · 784 Bytes
/
Copy pathkeys.js
File metadata and controls
19 lines (19 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var path = require('path'),
home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
fs = require('fs');
module.exports = {
whatIsMyPublicKey: function() {
var pubKeyPath = path.join(home, '.ssh', 'id_rsa.pub');
if (fs.existsSync(pubKeyPath))
return "Your public key on this worker:\n"+fs.readFileSync(pubKeyPath);
else
return "You do not have a public key on this worker. Expected "+pubKeyPath+" to exist";
},
getPrivateKey: function(optionalKey, callback) {
if (optionalKey) { callback(null, optionalKey) } else {
var keyPath = path.join(home, '.ssh', 'id_rsa');
if (fs.existsSync(keyPath)) callback(null, fs.readFileSync(keyPath).toString());
else callback(new Error("No private key available!"));
}
}
}