logo
0
0
WeChat Login
初始提交:SSH over WebSocket扩展

SSH over WebSocket

通过WebSocket隧道连接SSH服务的VSCode扩展。

功能

  • WebSocket隧道访问SSH
  • 自动下载websocat
  • 自动分配本地端口
  • 文件管理Headers(支持复杂Cookie)
  • 手动管理连接生命周期

使用

  1. 侧边栏点击"+"添加连接,输入URL(支持http/https自动转ws/wss)
  2. 右键"编辑Headers"打开文件编辑器,添加Cookie等headers
  3. 点击inline按钮打开Remote SSH
  4. 点击断开按钮清理连接
  5. 支持多选删除(Ctrl+点击或Delete键)

Headers文件格式

# 每行一个header,格式:Name: Value Cookie: _xsrf=xxx; user=yyy; ... Authorization: Bearer token

工作原理

  1. 启动websocat:websocat -b -E tcp-l:127.0.0.1:PORT wss://...
  2. 读取headers文件并传递给websocat
  3. 添加SSH config:Host example.com--notebook_123 → localhost:PORT
  4. 打开Remote SSH窗口
  5. 手动断开时清理websocat进程和SSH config

服务端

远程容器运行websockify:

apt-get install -y openssh-server websockify service ssh start websockify 0.0.0.0:8888 localhost:22

数据存储

  • 连接配置:~/.ssh-over-ws/state.json
  • Headers文件:~/.ssh-over-ws/headers/example.com--notebook_123.txt
  • SSH配置:~/.ssh/config
  • websocat:~/.ssh-over-ws/bin/