feat(sshclient): add a promise-first SSH client with secure host verification and improve SSH key/config handling
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import * as plugins from './smartssh.plugins.js';
|
||||
import * as helpers from './smartssh.classes.helpers.js';
|
||||
import { SshInstance } from './smartssh.classes.sshinstance.js';
|
||||
import { SshKey } from './smartssh.classes.sshkey.js';
|
||||
import { SshConfig } from './smartssh.classes.sshconfig.js';
|
||||
|
||||
@@ -13,32 +12,31 @@ export class SshDir {
|
||||
this._sshKeyArray = sshKeyArray;
|
||||
this._sshConfig = sshConfig;
|
||||
if (sshDirPathArg) {
|
||||
this._path = sshDirPathArg;
|
||||
this._path = helpers.resolveSshDirPath(sshDirPathArg);
|
||||
} else {
|
||||
this._path = plugins.path.join(plugins.smartpath.get.home(), '.ssh/');
|
||||
this._path = helpers.resolveSshDirPath();
|
||||
}
|
||||
}
|
||||
|
||||
writeToDir(dirPathArg?: string) {
|
||||
// syncs sshInstance to directory
|
||||
let path = this._path;
|
||||
if (dirPathArg) path = dirPathArg;
|
||||
if (dirPathArg) path = helpers.resolveSshDirPath(dirPathArg);
|
||||
this._sshKeyArray.forEach((sshKeyArg) => {
|
||||
sshKeyArg.store(path);
|
||||
sshKeyArg.storeSync(path);
|
||||
});
|
||||
this._sshConfig.store(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: implement reading of directories
|
||||
*/
|
||||
readFromDir(dirPathArg?: string) {
|
||||
// syncs sshInstance from directory
|
||||
let path = this._path;
|
||||
if (dirPathArg) path = dirPathArg;
|
||||
if (dirPathArg) path = helpers.resolveSshDirPath(dirPathArg);
|
||||
const sshKeys = helpers.sshKeyArrayFromDir(path);
|
||||
this._sshKeyArray.splice(0, this._sshKeyArray.length, ...sshKeys);
|
||||
}
|
||||
updateDirPath(dirPathArg: string) {
|
||||
this._path = dirPathArg;
|
||||
this._path = helpers.resolveSshDirPath(dirPathArg);
|
||||
}
|
||||
|
||||
getKeys() {
|
||||
|
||||
Reference in New Issue
Block a user