前言¶
團隊裏常見這樣的情況:Agent 要在本地跑構建、跑測試,代碼和數據卻放在遠端機器上。傳統做法是手動 sshfs 掛載一次,把路徑寫進文檔,從此每臺新機器、每個新 profile 都要重來一遍;命令行工具(如 nrs-tools/lib/autosshfs.js)能批量掛載,但沒有界面,狀態不直觀,也沒法讓 Agent 安全地操作。
下面介紹 shudingbo/dsh-plugin-autosshfs。它是 DeepSeek Harness 的客戶端插件,維護者 shudingbo,把 autosshfs 的 sshfs 掛載 / 卸載能力做成 Harness 主界面裏的獨立管理頁,同時以 autosshfs 工具把同一套邏輯暴露給 Agent。社區目錄把它歸在「客戶端」分類,當前星標爲 0。插件純 JavaScript,MIT 許可,package.json 版本 1.0.3。
這是什麼¶
一句話定位:在 Linux / macOS 上用 sshfs 掛載、卸載遠端目錄,界面上點按鈕操作,Agent 側也能調用。
幾個關鍵點:
- 入口是左側欄的全局面板按鈕,和「插件」「自動化任務」同一排。點擊後在主界面打開獨立頁面,不是設置彈窗。
- 配置文件沿用命令行版的
~/.autosshfs.json,位置和格式都不變。已經用命令行版攢下的配置可以直接複用。 - 所有操作(列表、狀態、增刪改、掛載 / 卸載、依賴檢測)界面和 Agent 工具共用同一套邏輯,不存在「界面能做、工具做不到」的落差。
核心功能¶
界面與 Agent 工具 autosshfs 的能力一一對應:
| 功能 | 界面 | Agent 工具 |
|---|---|---|
| 查看所有配置項與實時掛載狀態 | 支持 | action: "state" |
| 新增 / 編輯 / 刪除配置項 | 支持 | add / update / remove |
| 啓用 / 停用單項 | 支持 | enable |
| 掛載 / 卸載單項 | 支持 | mount / umount + name |
| 全部掛載 / 全部卸載 | 支持 | mount / umount(不帶 name) |
| 查看單項詳情(掛載來源、掛載選項等) | 支持 | detail |
| 系統依賴檢測與自動安裝 | 支持 | check(install 僅限界面) |
界面側補充幾點:頂欄有標題、sshfs 版本徽標、已掛載/總數 徽標和配置文件路徑;頂部有依賴提示條;列表頁支持按名稱 / 主機 / 掛載點搜索和全部 / 已啓用 / 已掛載篩選;點擊「詳情」就地展開掛載來源、文件系統、掛載選項和認證方式。界面中英雙語,隨 Harness 語言切換。
install 這個動作刻意只放在界面上,避免 Agent 擅自改動機器權限。
相對命令行版的兩處加固¶
README 明確寫了兩點改動,值得單獨說:
- 不再拼接 shell 字符串。所有命令以 argv 數組直接執行,主機名、路徑、密碼裏的任何字符都不會被 shell 解釋。使用
password字段的場景下這點尤其重要。 - 掛載狀態按掛載表精確匹配掛載點。Linux 讀
/proc/self/mounts,macOS 解析mount,替掉了原來在mount輸出裏做includes(path)的子串比較。/mnt/a不會再被誤判成/mnt/ab已掛載。
另外,配置寫入採用「臨時文件 + rename」的原子寫,文件權限固定 0600,因爲配置裏可能存着密碼。
安裝與啓用¶
插件是基於 dsh.bundle.patch + dsh.client 的 Harness bundle,沒有構建步驟,index.js / client.js / host/ 就是可直接運行的源碼。
方式一:從 GitHub 安裝¶
在 Harness 會話裏執行:
plugin_manager(action: "install_bundle", target: "github:shudingbo/dsh-plugin-autosshfs")
也可以把同一串 github:shudingbo/dsh-plugin-autosshfs 粘貼到 Harness Web 界面「插件 → 添加插件」的安裝框裏。安裝結果裏出現 application: applied 表示已生效。
底層是 pnpm 的 git 依賴,所以本質上等同於:
cd ~/.dsh/profiles/<profile>
pnpm add github:shudingbo/dsh-plugin-autosshfs
方式二:從本地目錄安裝¶
用於開發調試:
git clone git@github.com:shudingbo/dsh-plugin-autosshfs.git
plugin_manager(action: "install_bundle", target: "/絕對路徑/dsh-plugin-autosshfs")
方式零:從 npm 安裝¶
README 標註的方式零是發佈到 npm 後可用的方式,只有它能享受插件頁的「檢查更新 / 一鍵升級」:
plugin_manager(action: "install_bundle", target: "@shudingbo/dsh-plugin-autosshfs")
安裝之後¶
左側欄點擊 Autosshfs 掛載 面板按鈕,主界面切換到獨立管理頁。不想讓它常駐一行時,點該行右側的固定按鈕,它會收進「更多」菜單,再點固定即可放回。Agent 此時可以直接調用 autosshfs 工具。卸載用:
plugin_manager(action: "remove_bundle", target: "@shudingbo/dsh-plugin-autosshfs")
典型用法¶
安裝完成後,Agent 側的調用示例如下:
// 列出現狀
{ "action": "state" }
// 掛載全部啓用的配置
{ "action": "mount" }
// 只掛載某一項
{ "action": "mount", "name": "project" }
// 新增配置
{ "action": "add", "entry": { "name": "p", "host": "h", "user": "me", "remotePath": "/srv", "mount": "/mnt/p" } }
// 修改(只傳要改的字段,password 省略 = 保持,傳 "" = 清除)
{ "action": "update", "name": "p", "entry": { "allowOther": false } }
// 同名項可改用位置定位
{ "action": "detail", "index": 4 }
// 查看依賴問題
{ "action": "check" }
返回值是 JSON:{ ok, action, data | error, summary },error.code 和結果項的 code 是穩定標識,hint / command 給出下一步可執行動作。
界面上的操作順序一般是:先在「新增掛載」裏填好連接信息和掛載選項,再用開關或按鈕手動掛載;之後任何一次「全部掛載」都會跳過 enable 爲 false 的項。
配置與掛載選項¶
默認配置路徑 ~/.autosshfs.json,可用環境變量 AUTOSSHFS_CONFIG 覆蓋,兩者都支持 ~ 展開。結構示例:
{
"list": [
{
"enable": true,
"name": "project",
"host": "example.com",
"port": 22,
"user": "me",
"password": "",
"IdentityFile": "~/.ssh/id_ed25519",
"remotePath": "/srv/project",
"mount": "/mnt/project",
"allowOther": true,
"uid": "1000",
"gid": "1000",
"extraOptions": ["reconnect", "ServerAliveInterval=15"]
}
]
}
常用字段:
name:界面與工具按它定位配置項,新建時校驗唯一性。歷史配置若存在同名項,界面按「位置 + 名稱」定位。host/port/user:SSH 目標,user爲空時使用當前本地用戶。password:可選,存在時用-o password_stdin通過 stdin 傳入。明文保存在配置文件中,不建議長期使用,優先IdentityFile或 ssh-agent。IdentityFile:私鑰路徑,支持~/。remotePath:遠端目錄。mount:本地掛載點,絕對路徑,不存在會自動創建。enable:是否參與「全部掛載」,缺省視爲false。allowOther:是否附加allow_other,默認true。uid/gid:透傳uid=/gid=。extraOptions:額外-o選項,數組或以逗號 / 空格分隔的字符串。
未識別的字段在保存時會原樣保留,方便手工擴展。
系統依賴¶
插件會在「使用幫助 → 系統依賴」裏顯示依賴狀態。Linux 上若檢測到包管理器且 sudo -n 可用,頁面上的「自動安裝」按鈕可直接安裝,否則展示需要手動執行的命令。
Linux 各發行版安裝命令:
# Debian / Ubuntu
sudo apt-get install -y sshfs
# Fedora / RHEL
sudo dnf install -y fuse-sshfs
# Arch
sudo pacman -S --noconfirm sshfs
# openSUSE
sudo zypper --non-interactive install sshfs
# Alpine
sudo apk add sshfs
非 root 用戶使用 allow_other 前,需要在 /etc/fuse.conf 中啓用 user_allow_other:
sudo sed -i 's/^#\s*user_allow_other/user_allow_other/' /etc/fuse.conf
容器內還要把 /dev/fuse 傳入容器,並確保 FUSE 內核模塊可用(sudo modprobe fuse)。
macOS 上 Homebrew 已不再提供官方 sshfs 公式,需要自行選一套 FUSE 實現:
# 方案 A:FUSE-T(無需內核擴展)
brew tap macos-fuse-t/homebrew-cask
brew install --cask fuse-t
brew install fuse-t-sshfs
# 方案 B:macFUSE(內核擴展,需重啓並在「系統設置 → 隱私與安全性」中允許)
brew install --cask macfuse
brew install gromgit/fuse/sshfs-mac
macOS 的 allow_other 需先在 FUSE 提供方設置裏允許其他用戶,否則插件會自動退回不帶 allow_other 的掛載方式並給出警告,此時只有當前用戶能訪問掛載點。
適用場景與注意¶
適合的場景:Linux / macOS 上的 DSH 使用者,已經有命令行版 autosshfs 配置想平移到界面和 Agent;需要在 Agent 工作流裏按需掛載遠端目錄,而不是每次手動執行 shell。
幾條限制需要提前知道:
- 插件以當前 DSH 進程的權限運行,掛載、卸載、依賴安裝都直接作用在本機。安裝前先讀一遍源碼,確認
host/sshfs.js、host/config.js裏的實現符合預期;許可證是 MIT,作者 shudingbo。 - 只支持 Linux 與 macOS,Windows 不支持。
- 從 GitHub 安裝的插件沒有「檢查更新」入口,DSH 本身也沒有後臺自動更新。更新方式是先卸載再安裝,讓 git 依賴重新解析默認分支的最新提交:
plugin_manager(action: "remove_bundle", target: "@shudingbo/dsh-plugin-autosshfs")
plugin_manager(action: "install_bundle", target: "github:shudingbo/dsh-plugin-autosshfs")
想控制升級節奏,可以固定到 tag 或提交,例如 github:shudingbo/dsh-plugin-autosshfs#v1.0.1。已安裝的包不能直接用 install_bundle 覆蓋,帶 HMR 的 profile 會拋 already-installed,所以升級一律先卸載再安裝。本地 link: 安裝是例外,改動即生效。
小結¶
這個插件做的事不復雜:把 sshfs 掛載管理從命令行搬進 Harness 主界面,同時以 autosshfs 工具暴露同一套操作。配置格式沿用 ~/.autosshfs.json,命令行版的存量配置直接可用;argv 執行和掛載點精確匹配兩處加固降低了使用 password 和相似路徑時的風險。適合想在 Agent 工作流中按需掛載遠端目錄、又不希望每次都手工敲 sshfs 的人。
目錄頁:https://www.skillhub.cn/plugins/shudingbo/dsh-plugin-autosshfs
GitHub:https://github.com/shudingbo/dsh-plugin-autosshfs