@xtail/ssh
Version:
X-Tail SSH 库,包含 SSH 连接服务器的类和工具方法等
26 lines (25 loc) • 1.19 kB
TypeScript
import { default as SSHConfig } from 'ssh2-promise/lib/sshConfig';
import { SSHResultType } from '../types';
/**
* 测试 SSH 连接(对于报错未进行处理,直接返回错误对象)
*
* @param config SSH 连接配置(host/port/username/password 等)
* @param testCommand 用于验证 SSH 连接是否成功的测试命令,默认为 `echo "Connection test"`
* @returns 返回值 测试结果
*/
export declare const testConn: (config: SSHConfig, testCommand?: string) => Promise<SSHResultType>;
export type TestConnType = typeof testConn;
/**
* 测试 SSH 连接(对于报错使用 {@link SSHErrorMiddleware} 进行处理)
*
* @param config SSH 连接配置(host/port/username/password 等)
* @param options 配置选项
* - testCommand 用于验证 SSH 连接是否成功的测试命令,默认为 `echo "Connection test"`
* - timeout 超时时间(毫秒,默认 5000ms)
* @returns 返回值 测试结果
*/
export declare const testConnWithErrMiddleware: (config: SSHConfig, options?: {
testCommand?: string;
timeout?: number;
}) => Promise<SSHResultType>;
export type TestConnWithErrMiddlewareType = typeof testConnWithErrMiddleware;