翻译[9]-让sshfs再次伟大于浏览器中

news/2025/11/9 16:20:13/文章来源:https://www.cnblogs.com/qsbye/p/19204416

让sshfs再次伟大于浏览器中

  • 原文地址: [https://hackmd.io/@q/sftp-over-ws]
  • 原作者: qbane

让sftp/sshfs再次伟大

本文是一份“待办清单”,整理了在 SFTP 原始规范草案已过期、濒临被遗忘之后,可供研究与实验的协议资源。
我的愿望:让 SFTP 重新被广泛采用并焕发新生。


我的具体使用场景

  1. 与 Web 应用通过 SFTP 通信
  2. 把服务器端“基于文件系统”的程序,与操作同一目录树的 Web 客户端桥接起来
  3. 把浏览器当成 SFTP 客户端

现代方案

websocketfs(推荐)

  • 仓库:https://github.com/sagemathinc/websocketfs
  • 包含两个子包
    • websocket-sftp:协议层(传输层)
    • websocketfs:FUSE 集成层
  • 借助 libfuse2 的 Node 绑定,彻底摆脱 sshfs 依赖
  • 遗憾:目前 JS 生态暂无 libfuse3 绑定

我正在维护一份 websocketfs 分支,专注增强 websocket-sftp 包。


原始方案

sftp-ws( legacy )

  • 原始仓库:https://github.com/lukaaash/sftp-ws
  • 社区轻度维护版(仅升级工具链):https://github.com/Inveniem/sftp-ws

使用方式:需借助名为 vfs 的桥接程序

服务端示例

const SFTP = require('./lib/sftp')
const server = new SFTP.Server({port: 8888,virtualRoot: '.',readOnly: true,
})

客户端示例

npx vfs ws://localhost ./local --path PATH
  • 需自行打补丁,把端口参数传给 sshfs(-p PORT
  • 底层调用 sshfs localhost:PATH -o slave,通过 WebSocket 通道通信
  • 新版已把 -o slave 别名改为更包容的 passive

互操作性杀手锏

整个过程可逆
只要一条反向隧道即可让 SSH “客户端” 摇身变成 SFTP 服务器:

ssh -R xxxx:localhost:yyyy

这就是 SSHFS 最迷人的地方:只要 SSH 通,就能把任意文件系统镜像到任意机器。


GIO / GVfs 随手挂

gio mount sftp://USER@XYZ

挂载后路径示例

/run/user/1000/gvfs/sftp:host=XYZ,user=USER/SOME_PATH/…
  • 参考讨论:https://news.ycombinator.com/item?id=31813979
  • macOS 上暂时无法正常工作
  • GVfs 虽有文件监控机制,但大多数协议未实现

Green End SFTP Server

  • 官网:http://www.greenend.org.uk/rjk/sftpserver/
  • 仓库:https://github.com/ewxrjk/sftpserver

亮点

  • 维护活跃,支持 SFTP v3‒v6 全部版本
  • 附带易用的客户端脚本
  • 网站上有协议版本对比、扩展提案等背景资料

“SFTP over WebSocket” 实验配方

# 1. WebSocket 转发层
websocat -b --exit-on-eof ws-l:127.0.0.1:8888 lengthprefixed:tcp:127.0.0.1:9999# 2. SFTP 服务器
gesftpserver -H 127.0.0.1 -L 9999 --debug --websocat

长度前缀帧格式对 SFTP 而言属冗余,但能跑通。


SSHFS 活跃分支(上游已归档)

以下排名不分先后

仓库 特色
https://github.com/rozhuk-im/sshfs 多分支补丁合集
https://github.com/deadbeefsociety/sshfs 非常活跃,含大量补丁
https://github.com/neunenak/sshfs 含 Rust 移植版
https://github.com/stevenxxiu/sshfs 仅支持 SFTP v6

2023-08-29 完成的 GitHub 全库扫描结果


速查链接

本人整理的参考表:https://hackmd.io/BplmLAiDSZekdat-G8-gqA

冷知识
Chromium OS 内置了 SSHFS!
如果你在较新 Chromebook 启动 Linux 子系统时看到“SSHFS is launching”,就是它。
源码:https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/net-fs/sshfs/

延伸阅读
Samba Wiki:〈在服务器本地编辑文件〉互操作性指南
https://wiki.samba.org/index.php/Editing_files_locally_on_server:_interoperability

个人吐槽:SMB 支持文件变更监控,SFTP/SSHFS 能否也整一个?


Make SFTP/SSHFS Great Again
This page is a working list of resources for studying and experimenting with the SFTP protocol after its original specification draft has expired and is in danger of being forgotten. My hope is that SFTP will once again become widely adopted and awesome.

My specific use-cases are:

Communicate with web apps over SFTP
Bridge server-side filesystem-based programs with web clients that operate on the same directory tree
Use the browser as an SFTP client
websocketfs (modern)
Check out websocketfs: https://github.com/sagemathinc/websocketfs

It provides two packages:
websocket-sftp – the protocol (transport layer)
websocketfs – FUSE integration
Uses libfuse2 bindings for Node, eliminating the need for sshfs
Sadly I cannot find any libfuse3 binding in the JS ecosystem for now…

I am now maintaining a fork of websocketfs, aiming specifically to enhance the websocket-sftp package.

sftp-ws (legacy)
The original sftp-ws, SFTP over WebSocket: https://github.com/lukaaash/sftp-ws

There is a modern fork(?) https://github.com/Inveniem/sftp-ws
(merely updates the package so that it can be built with an up-to-date toolchain)

To use it, a bridge program vfs is required:

Server:

const SFTP = require('./lib/sftp')const server = new SFTP.Server({port: 8888,virtualRoot: '.',readOnly: true,
})

Client:

npx vfs ws://localhost ./local --path PATH

Note that you need to patch the code to accept a port argument and pass it to sshfs with -p PORT.

Under the hood it invokes sshfs localhost:PATH -o slave and communicates with it over the WebSocket channel.

(The option is aliased as passive in later versions, which is more inclusive.)

The interoperability
This is reversible! You can make the SSH “client” act as an SFTP server. All you need is a reverse tunnel:

ssh -R xxxx:localhost:yyyy
I think this is the best part of SSHFS: the interoperability. You can mirror part of a filesystem to other machines as long as you have a working SSH connection.

GIO?
Well, there is gio mount sftp://USER@XYZ after which you can access files under /run/user/1000/gvfs/sftp:host=XYZ,user=USER/SOME_PATH/…
goombacloud – https://news.ycombinator.com/item?id=31813979.

The support looks promising.
Cannot make it work under macOS.
Despite GVFS having a monitor mechanism, it is not implemented for most protocols.

Green End SFTP Server
Website: http://www.greenend.org.uk/rjk/sftpserver/
Repository: https://github.com/ewxrjk/sftpserver

It is a well-maintained SFTP server with a reasonable client for ad-hoc scripting. Supports all SFTP protocol versions from v3 to v6! You can also find background, extensions, comparisons between protocol versions, and more on its website.

SFTP over WebSocket
When experimenting with “SFTP over WebSocket” (that’s another story), I find it useful to pair a patched Green End SFTP Server with a patched websocat; commands shown below:

# WS server
websocat -b --exit-on-eof ws-l:127.0.0.1:8888 lengthprefixed:tcp:127.0.0.1:9999
# SFTP server
gesftpserver -H 127.0.0.1 -L 9999 --debug --websocat

The length-prefixed message framing technique is redundant for SFTP, but it works anyway.

Active forks of SSHFS
Because the upstream repo is archived, development takes place in various forks (not sorted):

https://github.com/rozhuk-im/sshfs – several patch branches (diff)
https://github.com/deadbeefsociety/sshfs – very active, includes patches! (diff)
https://github.com/neunenak/sshfs – includes a Rust port!
https://github.com/stevenxxiu/sshfs – supports and only supports SFTP v6!
Full fork scan on GitHub, retrieved 2023/8/29:

Useful links
Reference tables organized for myself:
https://hackmd.io/BplmLAiDSZekdat-G8-gqA

Chromium OS has SSHFS inside! If you have access to a recent Chrome OS device, you may have seen text like “SSHFS is launching” during the initialization phase of its Linux subsystem.
https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/net-fs/sshfs/

https://wiki.samba.org/index.php/Editing_files_locally_on_server:_interoperability
— My comment: SMB has a file alteration monitor; wondering if this is doable in the SFTP/SSHFS context?

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/960558.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python 多个excel合并

excel是这样的 多个这样的合并import pandas as pd import os import globdef merge_excel_files_with_source(input_folder, output_file):"""批量合并Excel文件,并添加来源文件列Parameters:input_f…

详细介绍:15:00开始面试,15:06就出来了,问的问题有点变态。。。

详细介绍:15:00开始面试,15:06就出来了,问的问题有点变态。。。pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: &qu…

计算机毕业设计-基于Java的口腔管理平台系统创建实战(附源码+论文+演示视频)

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

唯识主义:哲学爱智慧本质的当代回归 - 实践

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

第一届湖南省信息学拔尖创新挑战活动 总结

\(100+85+40+40=265\)。 拜谢 T4 放水了暴力多给了 \(20\)。可恶 T2 没给初值为极负值而痛失 \(15\)。愤恨 T3 没想到记搜错过正解。 我是 fw,我叫 fw! Pro.A 简单题,对怪兽的战斗力从小到大排序,按着这个顺序来打…

U629961 焦头烂额的日奈委员长 の markdown

U629961 焦头烂额的日奈委员长 题目背景 由于美食研究部的众人绑架了枫香,所以今天的歌赫娜由朱莉提供。 但是由于某些众所周知的原因,今天的午饭不仅无法正常开饭,为师的大可爱还需要处理这些活蹦乱跳冒着绿色粘液…

Java数组——Array类讲解

Java数组——Array类讲解Array工具类 数组的工具类java.util.Arrays 数组对象本身供调用的方法少,但API提供了一个工具类Arras供于使用,从而对数据对象进行一些基本操作 查看JDK帮助文档 Arrays类中方法都是用static…

论文笔记(九十三)ManipulationNet: Benchmarking - 实践

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

flask: 用flask-wtf校验参数

一,安装第三方库 $ pip3 install flask-wtf 二,例子 # validator from flask_wtf import FlaskForm import wtforms from wtforms import validators from wtforms.fields import StringField, TextAreaField, Integ…

序列密码的线性滤波模型

线性滤波模型的可攻击性分析 1. 线性滤波模型若 \(g(x)\) 是线性函数,即: \(d_i = a \cdot S^{(i)} = a_{L-1}s_{L-1}^{(i)} \oplus \cdots \oplus a_0 s_0^{(i)}\) 状态转移由矩阵 \(A\) 描述: \(S^{(i)} = A^i \c…

使用Milvus和DeepSeek构建RAG demo - 实践

使用Milvus和DeepSeek构建RAG demo - 实践2025-11-09 15:50 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: bloc…

python里字面量是什么?

在 Python 里,字面量(literal)就是“写在源码里、解释器一看就能直接算出值”的常量写法,不需要再经过变量查找或函数调用。 常见几类:类型 字面量示例 说明数字 42 -3.14 0xFF 1_000_000 3+4j 整型、浮点、十六进…

圆锥滚子轴承品牌:行业顶尖选择与专业解析

副标题:深入探讨2025年市场趋势与用户痛点解决方案 摘要 圆锥滚子轴承行业在2025年持续增长,受益于汽车、工程机械等领域的强劲需求,技术创新和高质量交付成为竞争核心。本文基于行业数据和分析,为您呈现前十名品牌…

串串重学

对于现在大部分的博客对于字符串串的说明看了一下,实在是硬套理论,定义,不能有一个如何而来的推导过程,无法深刻理解到自动机与 fail 指针的本质。 所以尝试自己写一写,但是我是鸽王 qwq 不一定按难度排序,可以看…

如何写毕业论文?10个高效写作技巧+AI论文工具推荐(2025最新)

撰写学术论文常让人无从下手,本文提供10个高效写作技巧及实用AI工具PaperNex。技巧包括明确研究主题目标、深入文献综述、制定大纲等。如明确研究问题和目标,借助学术数据库查阅文献,用AI生成大纲等。还推荐了Paper…

avro 数据入门

avro 数据入门1.概述 Apache Avro 是一种 开源的、语言无关的、基于行的(row-based)数据序列化格式,由 Hadoop 项目开发,广泛用于大数据生态系统(如 Kafka、Spark、Flink、Hive 等)中,用于高效存储和传输结构化…

Day 21

算法复习日:把“似懂非懂”的逻辑磨到通透 原本以为算法复习就是再刷几道题,可坐在电脑前打开之前的笔记才发现,很多算法只是“会写代码”,却没吃透底层逻辑——今天特意放慢节奏,对着二分查找、快速排序这两个“…

2025龙信杯个人Wp

服务器基本没做,时间太赶了www 一、 手机镜像检材 (共24题) 1.​ 分析手机镜像,请问机身的Wi-Fi 信号源的物理地址是什么?[标准格式:01:02:03:04:05:06] 00:db:60:6e:86:132.​ 分析手机镜像,请问张大的手机号码尾…

7大AI论文写作工具必备!论文写作辅助神器推荐!

临近毕业季,写毕业论文让不少人痛苦不堪。2025 年 AI 技术飞跃,成为学生的“学术神器”。作者亲自试用全网热门的 7 个 AI 写作工具,其中瑞达写作表现出色。文章详细介绍了包括瑞达写作、QuillBot、图灵论文 AI 写作…