fix: now ssh connection use use private key instead of the default

This commit is contained in:
Levi Yan
2024-10-28 19:02:56 +08:00
parent b279860ebe
commit d79a4a8243
2 changed files with 8 additions and 2 deletions

View File

@@ -12,8 +12,8 @@ export default class DSHome {
constructor(context: vscode.ExtensionContext) { constructor(context: vscode.ExtensionContext) {
this.context = context; this.context = context;
this.remoteContainer = new RemoteContainer();
this.user = new User(context); this.user = new User(context);
this.remoteContainer = new RemoteContainer(this.user);
} }
async toggle(url: string = DSHome.defaultUrl) { async toggle(url: string = DSHome.defaultUrl) {

View File

@@ -6,8 +6,14 @@ import * as rd from 'readline'
const { NodeSSH } = require('node-ssh') const { NodeSSH } = require('node-ssh')
import * as utils from './utils'; import * as utils from './utils';
import User from './user';
export default class RemoteContainer { export default class RemoteContainer {
private user:User;
constructor(user:User) {
this.user = user
}
async firstConnect(host: string, username: string, port: number): Promise<string>; // connect with key async firstConnect(host: string, username: string, port: number): Promise<string>; // connect with key
// deprecated // deprecated
@@ -29,7 +35,7 @@ export default class RemoteContainer {
host: host, host: host,
username: username, username: username,
port: port, port: port,
privateKey: utils.getDefaultPrivateKey() privateKeyPath: this.user.getUserPrivateKeyPath()
}); });
progress.report({ message: "连接成功,开始安装" }); progress.report({ message: "连接成功,开始安装" });