smb-client
Skill9 starsChanged 4 months agoMITView on GitHub
当用户要求"连接 SMB"、"访问 Windows 共享"、"查看 NAS 共享文件夹"、"下载/上传 SMB 文件"、"读取远程局域网共享"、"CIFS 文件管理"、"列出服务器共享列表"时使用此 skill。内置双引擎(系统 smbclient + 纯 JS 回退),单文件 skill.js 即开即用。
- Installs packages
In this repository64 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- cmo-weather-query/CLAUDE.mdCLAUDE.md
- db_client/CLAUDE.mdCLAUDE.md
- deepseek-search/CLAUDE.mdCLAUDE.md
- documents_ripgrep/CLAUDE.mdCLAUDE.md
- excel-alasql/CLAUDE.mdCLAUDE.md
- game_mahjong_agent/CLAUDE.mdCLAUDE.md
- gaode_map/CLAUDE.mdCLAUDE.md
- magpie-image-gen/CLAUDE.mdCLAUDE.md
- ms_office_x_editer/CLAUDE.mdCLAUDE.md
- ssh2-node/CLAUDE.mdCLAUDE.md
- use_http_mcp/CLAUDE.mdCLAUDE.md
- where-am-i/CLAUDE.mdCLAUDE.md
- 88chaSkill
- agent-browserSkill
- baidu-search-nodejsSkill
- brz-repair-manual-querySkill
- cmo-weather-querySkill
- db-clientSkill
- deepseek-searchSkill
- dianping-searchSkill
- doc-readerSkill
- documents-ripgrepSkill
- drawio-nodejsSkill
- excel-alasqlSkill
- figma-code-connectSkill
- figma-create-design-system-rulesSkill
- figma-create-new-fileSkill
- figma-generate-designSkill
- figma-generate-librarySkill
- figma-implement-designSkill
- figma-useSkill
- file-code-boxSkill
- financialSkill
- game-mahjong-agentSkill
- gaode-mapSkill
- gitea-apiSkill
- happy-agent-easySkill
- hindsightSkill
- jina-readerSkill
- kavita-liteSkill
- magpie-image-genSkill
- magpie-toolsSkill
- makepad-evolutionSkill
- markitdown-pdfSkill
- memos-nodeSkill
- mind-map-skillSkill
- ms-office-x-editerSkill
- nexus3-skillSkill
- obsidian-basesSkill
- obsidian-cliSkill
- json-canvasSkill
- ocr-toolSkill
- opencode-go-usageSkill
- sendmailSkill
- siyuan-apiSkill
- ssh2-nodeSkill
- use-http-mcpSkill
- website-security-scanSkill
- where-am-iSkill
- The first 60 shown.
The file
Files
SMB / CIFS 客户端工具 (smb-client)
连接 SMB/CIFS 共享并完成浏览、读取、下载、上传、目录管理等操作。内置双引擎:
- smbclient 引擎:检测到系统已安装
smbclient时优先使用; - 纯 JS 引擎:未安装 CLI 或 CLI 执行失败且已提供
share时自动回退,依赖已打包进skill.js,无需npm install。
快速开始
# 1. 测试连通性与认证(推荐用 smb:// URL)
node skill.js test --url "smb://username:your_password@smb.example.com/myshare"
# 2. 列出远程目录(--json 便于程序解析,--recursive 递归)
node skill.js ls "movies" --host smb.example.com --share myshare --user username --password your_password --json
# 3. 读取远程文件内容
node skill.js cat "docs/readme.txt" --smb "host:smb.example.com,share:myshare,user:username,password:your_password"
# 4. 下载 / 上传
node skill.js get "movies/intro.mp4" ./intro.mp4 --url "smb://username:your_password@smb.example.com/myshare"
node skill.js put ./report.pdf "docs/report.pdf" --url "smb://username:your_password@smb.example.com/myshare"
# 5. 列出服务器公开共享(需要 smbclient)
node skill.js shares --host smb.example.com --user username --password your_password --json命令总表
| 命令 | 用途 | 关键参数 |
test [path] | 测试连接与鉴权 | --host, --share 或 --url |
ls [remoteDir] | 列出远程目录文件与大小 | --json, --recursive |
stat <remotePath> | 查看文件/目录属性与类型 | --json |
cat <remoteFile> | 读取远程文件内容输出 | --max-bytes, --encoding |
get <remote> <local> | 下载文件到本地工作区 | 目标路径自动创建父目录 |
put <local> <remote> | 上传本地文件到 SMB 共享 | 自动创建远程父目录 |
mkdir <remoteDir> | 创建远程目录 | 自动递归创建多级目录 |
rm <remoteFile> | 删除远程文件 | 无 |
rmdir <remoteDir> | 删除远程空目录 | 无 |
rename <old> <new> | 重命名或移动远程文件 | 无 |
shares / list-shares | 列出服务器公开共享 | 需安装 smbclient |
选项
| 选项 | 说明 |
--json | 以标准 JSON 输出结果,便于 LLM 与程序解析 |
--recursive | ls 时递归列出子目录中的全部文件 |
--max-bytes <n> | cat 最大读取字节数,默认 10MB |
--encoding <enc> | 文本编码,默认 utf8 |
--timeout <ms> | smbclient 引擎单次执行超时,默认 30000 |
-v, --version | 显示版本号 |
-h, --help | 显示帮助 |
连接参数提供方式
优先级:命令行独立选项 > --smb 串 > smb:// URL > 环境变量。
1. smb:// URL(最推荐)
node skill.js ls "movies" --url "smb://username:your_password@smb.example.com/myshare"2. 紧凑参数串 (--smb)
node skill.js ls --smb "host:smb.example.com,share:myshare,user:username,password:your_password,domain:WORKGROUP"3. 独立参数
node skill.js ls --host smb.example.com --share myshare --user username --password your_password --domain WORKGROUP --port 4454. 环境变量
| 变量 | 说明 | 默认值 |
SMB_HOST | 服务器地址 | 空 |
SMB_SHARE | 共享名称 | 空 |
SMB_USER | 用户名 | guest |
SMB_PASSWORD | 密码 | 空 |
SMB_DOMAIN | 域或工作组 | WORKGROUP |
SMB_PORT | 端口 | 445 |
export SMB_HOST=smb.example.com
export SMB_SHARE=myshare
export SMB_USER=username
export SMB_PASSWORD=your_password
node skill.js ls引擎选择与输出
- 每条输出均带
engine字段:smbclient或js。 shares/list-shares依赖smbclient;纯 JS 引擎无法在未知share时枚举共享列表,会返回SMBCLIENT_REQUIRED错误并提示查看已挂载共享。- 错误统一输出
{ "success": false, "error": "...", "code": "..." },退出码 1。
{
"success": true,
"engine": "js",
"path": "/",
"count": 2,
"entries": [
{ "name": "movies", "path": "movies", "type": "directory", "size": null },
{ "name": "info.txt", "path": "info.txt", "type": "file", "size": 1024 }
]
}常见问题
- 连接超时 (ETIMEDOUT):确认目标主机与 445 端口可达(如
nc -z -w 3 <host> 445),检查防火墙与局域网路由。 - 认证失败 (STATUS_LOGON_FAILURE):核对用户名密码;Windows 或 AD 域设备需带
--domain。 - 共享不存在 (STATUS_BAD_NETWORK_NAME):
--share填共享名称(如video),不是物理路径。 shares报 SMBCLIENT_REQUIRED:安装 samba 客户端(如apt install smbclient),或改用mount/net use查看已挂载共享。- smbclient 引擎失败后自动回退:stderr 会给出
warning,最终结果以engine: "js"标记。
第三方开源致谢
本工具内置打包了 @marsaud/smb2 (MIT License)。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

