From 42dfe936b773b7bdd82ca3378363252ffffd7b71 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 21 Apr 2025 17:34:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20ssh=E4=BC=AA=E7=BB=88=E7=AB=AF=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=BC=98=E5=8C=96=EF=BC=8Cwindows=E4=B8=8B=E4=B8=8D?= =?UTF-8?q?=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/plugin-lib/src/ssh/ssh-access.ts | 19 +++++++++---------- packages/plugins/plugin-lib/src/ssh/ssh.ts | 7 ++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/plugins/plugin-lib/src/ssh/ssh-access.ts b/packages/plugins/plugin-lib/src/ssh/ssh-access.ts index 60c9d90a..ecf75519 100644 --- a/packages/plugins/plugin-lib/src/ssh/ssh-access.ts +++ b/packages/plugins/plugin-lib/src/ssh/ssh-access.ts @@ -63,16 +63,15 @@ export class SshAccess extends BaseAccess { }) passphrase!: string; - @AccessInput({ - title: "伪终端", - helper: "如果登录报错:all authentication methods failed,可以尝试开启伪终端模式进行keyboard-interactive方式登录", - value:false, - component: { - name: "a-switch", - vModel: "checked", - }, - }) - pty = false; + // @AccessInput({ + // title: "伪终端", + // helper: "如果登录报错:all authentication methods failed,可以尝试开启伪终端模式进行keyboard-interactive方式登录", + // component: { + // name: "a-switch", + // vModel: "checked", + // }, + // }) + // pty!: boolean; @AccessInput({ title: "socks代理", diff --git a/packages/plugins/plugin-lib/src/ssh/ssh.ts b/packages/plugins/plugin-lib/src/ssh/ssh.ts index 7000d570..b6322c47 100644 --- a/packages/plugins/plugin-lib/src/ssh/ssh.ts +++ b/packages/plugins/plugin-lib/src/ssh/ssh.ts @@ -170,9 +170,10 @@ export class AsyncSsh2Client { // } return new Promise((resolve, reject) => { this.logger.info(`执行命令:[${this.connConf.host}][exec]: \n` + script); - // pty 必须为false, 否则返回值会带上 所有输出,影响返回结果判断, 比如 root#: xxxx - // 当使用keyboard-interactive 登录时,需要pty - this.conn.exec(script, { pty: this.connConf.pty ?? false, env: opts.env }, (err: Error, stream: any) => { + // pty 伪终端,window下的输出会带上conhost.exe之类的多余的字符串,影响返回结果判断 + // linux下 当使用keyboard-interactive 登录时,需要pty + const pty = !this.connConf.windows //linux下开启伪终端,windows下不开启 + this.conn.exec(script, { pty, env: opts.env }, (err: Error, stream: any) => { if (err) { reject(err); return;