
billchurch/webssh2基于ssh2、socket.io、xterm.js和express的Web SSH客户端,提供HTML5网页终端模拟器和SSH客户端功能。通过在主机上使用SSH2作为客户端,将WebSocket/Socket.io连接代理到SSH2服务器,实现网页端SSH访问。
!WebSSH2 v0.2.0演示
WebSSH2 Docker镜像封装了Web SSH客户端应用,允许用户通过浏览器访问和管理SSH服务器。无需安装本地SSH客户端,只需通过网页即可建立SSH连接,适用于远程服务器管理、跨平台访问等场景。
billchurch/webssh2:latest:最新稳定版,对应官方最新发布版本billchurch/webssh2:<版本号>:指定版本,如0.4.6、0.4.7-alpha.2bash# 拉取最新稳定版 docker pull billchurch/webssh2 # 拉取指定版本 docker pull billchurch/webssh2:0.4.6
bashdocker run --name webssh2 -d -p 2222:2222 billchurch/webssh2
bash# 先准备配置文件(可从https://github.com/billchurch/webssh2/blob/0.4.6/app/config.json.sample获取模板) docker run --name webssh2 -d -p 2222:2222 -v $(pwd)/config.json:/usr/src/config.json billchurch/webssh2
bash# 克隆仓库 git clone https://github.com/billchurch/webssh2.git cd webssh2 git checkout current # 或指定版本标签 # 构建镜像 docker build -t webssh2 . # 运行本地镜像 docker run --name webssh2 -d -p 2222:2222 webssh2
环境变量会覆盖config.json中的对应配置,适用于容器化环境:
| 变量名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| LISTEN | string | 127.0.0.1 | 服务监听IP地址 |
| PORT | integer | 2222 | 服务监听端口 |
| SOCKETIO_ORIGINS | array | localhost:2222 | 允许的CORS源,使用*:*可允许所有(不推荐) |
| SOCKETIO_PATH | string | /ssh/socket.io | socket.io客户端文件路径 |
| SOCKETIO_SERVECLIENT | boolean | false | 是否提供socket.io客户端文件(通常不需要,内置在自定义JS中) |
通过POST请求传递连接参数:
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| username | string | - | SSH登录用户名 |
| userpassword | string | - | SSH登录密码 |
| port | integer | 22 | SSH服务器端口 |
| header | string | - | 页面显示的可选标题 |
| headerBackground | string | - | 标题背景颜色 |
| sshterm | string | vt100 | 终端模拟类型 |
| readyTimeout | integer | 20000 | SSH握手超时时间(毫秒) |
| cursorBlink | boolean | true | 光标是否闪烁 |
| scrollback | integer | *** | 回滚缓冲区行数 |
| tabStopWidth | integer | 8 | 制表符宽度 |
| bellStyle | string | sound | 终端提示音样式(sound/none) |
| fontSize | number | 12 | 字体大小 |
| fontFamily | string | - | 字体家族 |
| letterSpacing | number | - | 字符间距 |
| lineHeight | number | - | 行高 |
通过URL查询参数传递连接参数(与POST参数类似):
示例:http://localhost:2222/ssh/host/192.168.1.1?port=2244&header=My%20Header&headerBackground=red
配置文件包含详细自定义选项,JSON格式:
json{ "listen": { "ip": "127.0.0.1", "port": 2222 }, "socketio": { "serveClient": false, "path": "/ssh/socket.io", "origins": "localhost:2222" }, "user": { "name": null, "password": null, "overridebasic": false }, "ssh": { "host": null, "port": 22, "term": "vt100", "readyTimeout": 20000 }, "terminal": { "cursorBlink": true, "scrollback": 10000, "tabStopWidth": 8, "bellStyle": "sound", "fontSize": 14 } }
关键配置项说明:
点击状态栏的Start logging开始记录终端数据,记录开始后会显示Download log选项,可随时下载日志。点击Logging - STOP LOG停止记录,再次点击Start logging会覆盖当前日志(建议先下载)。
访问部署后的WebSSH2服务:
http://localhost:2222/ssh/host/192.168.1.1?port=2244&header=My%20Header&headerBackground=red
访问后会通过HTTP Basic Auth提示输入SSH用户名和密码,验证通过后即可在浏览器中使用SSH终端。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务