47 lines
3.4 KiB
JavaScript
47 lines
3.4 KiB
JavaScript
"use strict";
|
|
require("typings-global");
|
|
const plugins = require("./smartssh.plugins");
|
|
class SshConfig {
|
|
constructor(sshKeyArrayArg) {
|
|
this._sshKeyArray = sshKeyArrayArg;
|
|
}
|
|
/**
|
|
* stores a config file
|
|
*/
|
|
store(dirPathArg) {
|
|
let done = plugins.q.defer();
|
|
let configArray = [];
|
|
let configString;
|
|
for (let key in this._sshKeyArray) {
|
|
let sshKey = this._sshKeyArray[key];
|
|
if (sshKey.host) {
|
|
configString = 'Host ' + sshKey.host + '\n' +
|
|
' HostName ' + sshKey.host + '\n' +
|
|
' IdentityFile ~/.ssh/' + sshKey.host + '\n' +
|
|
' StrictHostKeyChecking no' + '\n';
|
|
}
|
|
configArray.push({
|
|
configString: configString,
|
|
authorized: sshKey.authorized,
|
|
sshKey: sshKey
|
|
});
|
|
}
|
|
let configFile = '';
|
|
for (let key in configArray) {
|
|
configFile = configFile + configArray[key].configString + '\n';
|
|
}
|
|
;
|
|
plugins.smartfile.memory.toFsSync(configFile, plugins.path.join(dirPathArg, 'config'));
|
|
return done.promise;
|
|
}
|
|
read(dirPathArg) {
|
|
let done = plugins.q.defer();
|
|
let configArray;
|
|
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, 'config'));
|
|
return done.promise;
|
|
}
|
|
}
|
|
exports.SshConfig = SshConfig;
|
|
;
|
|
;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGNvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUk3QztJQUVJLFlBQVksY0FBd0I7UUFDaEMsSUFBSSxDQUFDLFlBQVksR0FBR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