py-web-ssh 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/PKG-INFO +3 -3
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/README.md +59 -59
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/pyproject.toml +1 -1
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/__init__.py +1 -1
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/app.py +11 -5
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/LICENSE +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/auth.py +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/files.py +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/history.py +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/models.py +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/session.py +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/ssh_client.py +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/static/app.js +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/static/index.html +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/static/logs.html +0 -0
- {py_web_ssh-0.1.1 → py_web_ssh-0.1.2}/webssh/static/styles.css +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: py-web-ssh
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A Python web SSH client with xterm.js, reconnectable sessions, logs, and file transfer.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -53,10 +53,10 @@ py-web-ssh
|
|
|
53
53
|
或者:
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
|
-
uvicorn webssh.app:app --host
|
|
56
|
+
uvicorn webssh.app:app --host 0.0.0.0 --port 8022
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
打开 <http://127.0.0.1:
|
|
59
|
+
打开 <http://127.0.0.1:8022>。
|
|
60
60
|
|
|
61
61
|
启用 PIN:
|
|
62
62
|
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
# py-web-ssh
|
|
2
|
-
|
|
3
|
-
一个基于 Python/FastAPI/Paramiko 的 Web SSH 客户端。前端使用 xterm.js 渲染真实终端控制序列,后端通过 WebSocket 转发 SSH 交互数据,并为每个网页客户端分配随机 UUID,支持同 UUID 断线重连、终端快照恢复、日志查看和文件上传下载。
|
|
4
|
-
|
|
5
|
-
## 功能
|
|
6
|
-
|
|
7
|
-
- SSH 交互终端:Paramiko 后端 `invoke_shell`,xterm.js 前端实时交互。
|
|
8
|
-
- 登录方式:密码、浏览器上传私钥、私钥口令、SSH agent、服务端本机 `~/.ssh` 密钥、免口令/none auth。
|
|
9
|
-
- Legacy 兼容:启动时按当前 Paramiko 运行时能力尽量启用旧 KEX/Cipher/MAC/HostKey/Pubkey 算法,并在日志中列出不可用算法。
|
|
10
|
-
- UUID 会话:创建会话后返回 UUID,WebSocket 断开后可用同 UUID 重连。
|
|
11
|
-
- 会话回收:同一个 UUID 如果所有浏览器连接都断开并且 5 分钟内无人重连,服务端会主动断开 SSH 并清理内存缓存。
|
|
12
|
-
- 终端恢复:服务端保存 SSH 输出流,浏览器定期回传 xterm serialize 快照;重连时先恢复快照,再补放快照之后的输出。
|
|
13
|
-
- 日志页面:`/sessions/{uuid}/logs` 展示完整连接、认证、错误和文件传输日志。
|
|
14
|
-
- 文件传输:优先 SFTP;SFTP 不可用时参考 `simple-ssh-copy` 思路,使用远端 `base64` shell 命令 fallback 上传/下载。
|
|
15
|
-
- 可选 PIN 门禁:服务端传入 `--pin` 后,网页启动时必须先输入正确 PIN;验证成功后浏览器会保存加盐哈希 cookie,后端会保护 HTTP API、日志页面、文件接口和 WebSocket。
|
|
16
|
-
|
|
17
|
-
## 安装
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
python -m venv .venv
|
|
21
|
-
.venv\Scripts\activate
|
|
22
|
-
pip install -e .
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## 启动
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
py-web-ssh
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
或者:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
uvicorn webssh.app:app --host
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
打开 <http://127.0.0.1:
|
|
38
|
-
|
|
39
|
-
启用 PIN:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
py-web-ssh --pin 123456
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
前端默认从 jsDelivr 加载 xterm.js、fit addon 和 serialize addon。离线内网部署时,请把这些静态资源 vendoring 到 `webssh/static/` 并替换 `index.html` 里的 CDN 地址。
|
|
46
|
-
|
|
47
|
-
## API 概览
|
|
48
|
-
|
|
49
|
-
- `POST /api/sessions` 创建 SSH 会话。
|
|
50
|
-
- `GET /api/sessions/{uuid}` 查看会话状态。
|
|
51
|
-
- `GET /api/sessions/{uuid}/logs` 获取完整日志 JSON。
|
|
52
|
-
- `DELETE /api/sessions/{uuid}` 主动断开 SSH。
|
|
53
|
-
- `WS /ws/sessions/{uuid}` 终端输入、输出、resize、快照和断开控制。
|
|
54
|
-
- `POST /api/sessions/{uuid}/files/upload` 上传文件,multipart 字段:`remote_path`、`file`。
|
|
55
|
-
- `GET /api/sessions/{uuid}/files/download?remote_path=/path/file` 下载远端文件。
|
|
56
|
-
|
|
57
|
-
## 安全提示
|
|
58
|
-
|
|
59
|
-
这个项目默认面向可信内网或本机使用。私钥和口令只保存在进程内存中,不写入日志;如果要暴露到公网,请务必加 HTTPS、登录认证、CSRF/来源限制、审计和会话回收策略。
|
|
1
|
+
# py-web-ssh
|
|
2
|
+
|
|
3
|
+
一个基于 Python/FastAPI/Paramiko 的 Web SSH 客户端。前端使用 xterm.js 渲染真实终端控制序列,后端通过 WebSocket 转发 SSH 交互数据,并为每个网页客户端分配随机 UUID,支持同 UUID 断线重连、终端快照恢复、日志查看和文件上传下载。
|
|
4
|
+
|
|
5
|
+
## 功能
|
|
6
|
+
|
|
7
|
+
- SSH 交互终端:Paramiko 后端 `invoke_shell`,xterm.js 前端实时交互。
|
|
8
|
+
- 登录方式:密码、浏览器上传私钥、私钥口令、SSH agent、服务端本机 `~/.ssh` 密钥、免口令/none auth。
|
|
9
|
+
- Legacy 兼容:启动时按当前 Paramiko 运行时能力尽量启用旧 KEX/Cipher/MAC/HostKey/Pubkey 算法,并在日志中列出不可用算法。
|
|
10
|
+
- UUID 会话:创建会话后返回 UUID,WebSocket 断开后可用同 UUID 重连。
|
|
11
|
+
- 会话回收:同一个 UUID 如果所有浏览器连接都断开并且 5 分钟内无人重连,服务端会主动断开 SSH 并清理内存缓存。
|
|
12
|
+
- 终端恢复:服务端保存 SSH 输出流,浏览器定期回传 xterm serialize 快照;重连时先恢复快照,再补放快照之后的输出。
|
|
13
|
+
- 日志页面:`/sessions/{uuid}/logs` 展示完整连接、认证、错误和文件传输日志。
|
|
14
|
+
- 文件传输:优先 SFTP;SFTP 不可用时参考 `simple-ssh-copy` 思路,使用远端 `base64` shell 命令 fallback 上传/下载。
|
|
15
|
+
- 可选 PIN 门禁:服务端传入 `--pin` 后,网页启动时必须先输入正确 PIN;验证成功后浏览器会保存加盐哈希 cookie,后端会保护 HTTP API、日志页面、文件接口和 WebSocket。
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
python -m venv .venv
|
|
21
|
+
.venv\Scripts\activate
|
|
22
|
+
pip install -e .
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 启动
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
py-web-ssh
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
或者:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uvicorn webssh.app:app --host 0.0.0.0 --port 8022
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
打开 <http://127.0.0.1:8022>。
|
|
38
|
+
|
|
39
|
+
启用 PIN:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
py-web-ssh --pin 123456
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
前端默认从 jsDelivr 加载 xterm.js、fit addon 和 serialize addon。离线内网部署时,请把这些静态资源 vendoring 到 `webssh/static/` 并替换 `index.html` 里的 CDN 地址。
|
|
46
|
+
|
|
47
|
+
## API 概览
|
|
48
|
+
|
|
49
|
+
- `POST /api/sessions` 创建 SSH 会话。
|
|
50
|
+
- `GET /api/sessions/{uuid}` 查看会话状态。
|
|
51
|
+
- `GET /api/sessions/{uuid}/logs` 获取完整日志 JSON。
|
|
52
|
+
- `DELETE /api/sessions/{uuid}` 主动断开 SSH。
|
|
53
|
+
- `WS /ws/sessions/{uuid}` 终端输入、输出、resize、快照和断开控制。
|
|
54
|
+
- `POST /api/sessions/{uuid}/files/upload` 上传文件,multipart 字段:`remote_path`、`file`。
|
|
55
|
+
- `GET /api/sessions/{uuid}/files/download?remote_path=/path/file` 下载远端文件。
|
|
56
|
+
|
|
57
|
+
## 安全提示
|
|
58
|
+
|
|
59
|
+
这个项目默认面向可信内网或本机使用。私钥和口令只保存在进程内存中,不写入日志;如果要暴露到公网,请务必加 HTTPS、登录认证、CSRF/来源限制、审计和会话回收策略。
|
|
@@ -21,6 +21,8 @@ from .session import SessionManager
|
|
|
21
21
|
BASE_DIR = Path(__file__).resolve().parent
|
|
22
22
|
STATIC_DIR = BASE_DIR / "static"
|
|
23
23
|
PUBLIC_PATHS = {"/", "/api/auth/status", "/api/auth/login", "/favicon.ico"}
|
|
24
|
+
DEFAULT_HOST = "0.0.0.0"
|
|
25
|
+
DEFAULT_PORT = 8022
|
|
24
26
|
|
|
25
27
|
app = FastAPI(title="py-web-ssh", version=__version__)
|
|
26
28
|
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
|
@@ -223,14 +225,18 @@ def _content_length(upload: UploadFile) -> int | None:
|
|
|
223
225
|
return None
|
|
224
226
|
|
|
225
227
|
|
|
228
|
+
def build_arg_parser() -> argparse.ArgumentParser:
|
|
229
|
+
parser = argparse.ArgumentParser(prog="py-web-ssh")
|
|
230
|
+
parser.add_argument("--host", default=DEFAULT_HOST, help="Host interface to bind.")
|
|
231
|
+
parser.add_argument("--port", type=int, default=DEFAULT_PORT, help="Port to listen on.")
|
|
232
|
+
add_pin_argument(parser)
|
|
233
|
+
return parser
|
|
234
|
+
|
|
235
|
+
|
|
226
236
|
def main() -> None:
|
|
227
237
|
import uvicorn
|
|
228
238
|
|
|
229
|
-
|
|
230
|
-
parser.add_argument("--host", default="127.0.0.1", help="Host interface to bind.")
|
|
231
|
-
parser.add_argument("--port", type=int, default=8000, help="Port to listen on.")
|
|
232
|
-
add_pin_argument(parser)
|
|
233
|
-
args = parser.parse_args()
|
|
239
|
+
args = build_arg_parser().parse_args()
|
|
234
240
|
|
|
235
241
|
configure_pin(args.pin)
|
|
236
242
|
uvicorn.run("webssh.app:app", host=args.host, port=args.port, reload=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|