mirror of https://github.com/certd/certd
perf: ssh PTY模式登录设置
parent
9b8f60b64b
commit
8385bcc2d7
|
@ -63,6 +63,17 @@ export class SshAccess extends BaseAccess {
|
||||||
})
|
})
|
||||||
passphrase!: string;
|
passphrase!: string;
|
||||||
|
|
||||||
|
@AccessInput({
|
||||||
|
title: "伪终端",
|
||||||
|
helper: "如果登录报错:all authentication methods failed,可以尝试开启伪终端模式进行keyboard-interactive方式登录",
|
||||||
|
value:false,
|
||||||
|
component: {
|
||||||
|
name: "a-switch",
|
||||||
|
vModel: "checked",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
pty = false;
|
||||||
|
|
||||||
@AccessInput({
|
@AccessInput({
|
||||||
title: "socks代理",
|
title: "socks代理",
|
||||||
helper: "socks代理配置,格式:socks5://user:password@host:port",
|
helper: "socks代理配置,格式:socks5://user:password@host:port",
|
||||||
|
|
|
@ -170,7 +170,9 @@ export class AsyncSsh2Client {
|
||||||
// }
|
// }
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.logger.info(`执行命令:[${this.connConf.host}][exec]: \n` + script);
|
this.logger.info(`执行命令:[${this.connConf.host}][exec]: \n` + script);
|
||||||
this.conn.exec(script, { pty: true, env: opts.env }, (err: Error, stream: any) => {
|
// pty 必须为false, 否则返回值会带上 所有输出,影响返回结果判断, 比如 root#: xxxx
|
||||||
|
// 当使用keyboard-interactive 登录时,需要pty
|
||||||
|
this.conn.exec(script, { pty: this.connConf.pty ?? false, env: opts.env }, (err: Error, stream: any) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
return;
|
return;
|
||||||
|
@ -475,7 +477,7 @@ export class SshClient {
|
||||||
script = envScripts.join(newLine) + newLine + script;
|
script = envScripts.join(newLine) + newLine + script;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return await conn.exec(script as string, { env: options.env });
|
return await conn.exec(script as string, {});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue