DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

wsy320 /

wsy320/dsh-ssh-exec

Verified

DSH plugin: dsh-ssh-exec

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@4aeec058

dsh-ssh-exec

一个只做一件事的 DSH 插件:注册 ssh_exec 工具,让 agent 能在没有交互终端的环境里登录远程主机执行命令。

解决什么问题

DSH 的 shell 是非交互的:

[Console]::IsInputRedirected  = True
[Console]::IsOutputRedirected = True

原生 ssh 客户端读密码走终端接口(CONIN$),没有 tty 就永远等不到密码。表现出来的不是 Permission denied,而是命令原地挂死——不报错、不返回,直到超时被杀。echo 密码 | ssh ... 也没用,OpenSSH 不读 stdin 管道取密码。

本插件用 ssh2 在进程内直接讲 SSH 协议:不调用 ssh 二进制, 不需要 tty,密码认证可以正常工作。

与 dsh-ssh 的区别

dsh-ssh dsh-ssh-exec
注册独立工具 ❌ ✅ ssh_exec
接管 ctx.subprocess / ctx.fs ✅(整个会话搬到远程) ❌ 本机 pwsh 与文件工具照常可用
适用 远程开发工作区 偶尔登录远程机器执行命令

两者可以共存;本插件不碰单槽位服务,因此不会改变本地执行环境。

安装

// ~/.dsh/profiles/<profile>/package.json
"dependencies": {
  "dsh-ssh-exec": "link:/path/to/dsh-ssh-exec"
},
"dsh": { "profile": { "bundles": [ /* … */ "dsh-ssh-exec" ] } }

然后在 profile 的 node_modules 里建立指向插件目录的符号链接(参考已有的 dsh-memory-vault), 重启 DSH。工具列表里会出现 ssh_exec。

主机表

默认读取 ~/.dsh/ssh_hosts.json(可用 hostsFile 配置项覆盖):

{
  "hosts": {
    "router": { "hostname": "192.168.1.1", "username": "root", "password": "…" },
    "nas":    { "hostname": "192.168.1.20", "username": "root", "passwordEnv": "NAS_PW",
                "via": "router" }
  }
}
字段 说明
hostname port username 连接目标,port 默认 22,username 默认 root
password 明文密码
passwordEnv 改从环境变量取密码,推荐;优先于 password
privateKey passphrase 私钥路径或 PEM 内容;未配置时回退 ~/.ssh/id_ed25519,再回退 SSH agent
via 跳板机别名,走 ssh2 的 forwardOut

不认识的 host 参数会被当成字面主机名/IP 直接连接。

工具参数

参数 说明
action run(默认语义)或 list
host 主机别名或 IP
command 要执行的命令(run 必填)
timeout 超时秒数,默认取配置 defaultTimeout(120)

返回一段文本:命令、stdout、stderr(非空时)、退出码;超过 maxOutput 会截断并标注。

配置项

字段 默认 说明
hostsFile ~/.dsh/ssh_hosts.json 主机表路径
defaultTimeout 120 默认超时(秒)
maxOutput 200000 单次返回最大字符数

已知限制

  • 每条命令独立建连,没有连接复用;高频调用会有握手开销。
  • 不做主机指纹校验(家用内网自签场景),如需严格校验可加 known_hosts 支持。
  • 远程 pid 不可见,无法定点杀进程;长任务请自带超时。

License

MIT

—/ 5

No ratings yet

Verified DSH bundle

Commit 4aeec0585f2f

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout