Documentation Index
Fetch the complete documentation index at: https://projectdiscovery.sec-lab.cn/llms.txt
Use this file to discover all available pages before exploring further.
类: SSHClient
ssh.SSHClient
SSHClient 是用于 SSH 服务器的客户端。
内部客户端使用 github.com/zmap/zgrab2/lib/ssh 驱动程序。
示例
const ssh = require('nuclei/ssh');
const client = new ssh.SSHClient();
构造函数
构造函数
constructor
• new SSHClient(): SSHClient
SSHClient
定义于
ssh.ts:16
Close
▸ Close(): boolean
Close 关闭 SSH 连接并销毁客户端
返回成功状态和错误。如果错误不为 nil,
状态将为 false
boolean
示例
const ssh = require('nuclei/ssh');
const client = new ssh.SSHClient();
client.Connect('acme.com', 22, 'username', 'password');
const closed = client.Close();
定义于
ssh.ts:118
Connect
▸ Connect(host, port, username): boolean
Connect 尝试使用提供的用户名和密码通过 ssh 连接到提供的主机和端口。
返回连接状态和错误。如果错误不为 nil,
状态将为 false
| 名称 | 类型 |
|---|
host | string |
port | number |
username | string |
boolean
示例
const ssh = require('nuclei/ssh');
const client = new ssh.SSHClient();
const connected = client.Connect('acme.com', 22, 'username', 'password');
定义于
ssh.ts:43
ConnectSSHInfoMode
▸ ConnectSSHInfoMode(host, port): HandshakeLog
ConnectSSHInfoMode 尝试连接到提供的主机和端口
返回 HandshakeLog 和错误。如果错误不为 nil,
状态将为 false
HandshakeLog 是一个包含有关 SSH 连接信息的结构体
HandshakeLog
示例
const ssh = require('nuclei/ssh');
const client = new ssh.SSHClient();
const info = client.ConnectSSHInfoMode('acme.com', 22);
log(to_json(info));
定义于
ssh.ts:81
ConnectWithKey
▸ ConnectWithKey(host, port, username): boolean
ConnectWithKey 尝试使用提供的用户名和私钥连接到提供的主机和端口。
返回连接状态和错误。如果错误不为 nil,
状态将为 false
| 名称 | 类型 |
|---|
host | string |
port | number |
username | string |
boolean
示例
const ssh = require('nuclei/ssh');
const client = new ssh.SSHClient();
const privateKey = `-----BEGIN RSA PRIVATE KEY----- ...`;
const connected = client.ConnectWithKey('acme.com', 22, 'username', privateKey);
定义于
ssh.ts:61
Run
▸ Run(cmd): string
Run 尝试打开一个新的 SSH 会话,然后尝试在该会话中执行提供的命令
返回字符串和错误。如果错误不为 nil,
状态将为 false
字符串包含命令输出
string
示例
const ssh = require('nuclei/ssh');
const client = new ssh.SSHClient();
client.Connect('acme.com', 22, 'username', 'password');
const output = client.Run('id');
log(output);
定义于
ssh.ts:101
SetTimeout
▸ SetTimeout(sec): void
SetTimeout 设置 SSH 连接的超时时间(以秒为单位)
void
示例
const ssh = require('nuclei/ssh');
const client = new ssh.SSHClient();
client.SetTimeout(10);
定义于
ssh.ts:26