基于web的ssh客户端

webssh的Python项目详细描述


Build StatuscodecovPyPI - Python VersionPyPI

简介

一个简单的Web应用程序,用作连接到 ssh服务器。它是用python编写的,基于tornado、paramiko和 xterm.js.公司

功能

  • 支持ssh密码验证,包括空密码。
  • 支持ssh公钥身份验证,包括dsa rsa ecdsa ED25519键。
  • 支持加密密钥。
  • 支持双因素身份验证(基于时间的一次性密码)。
  • 支持全屏终端。
  • 可调整终端窗口大小。
  • 自动检测ssh服务器的默认编码。
  • 现代浏览器包括Chrome、Firefox、Safari、Edge、Opera 支持。

预览

LoginTerminal

工作原理

+---------+     http     +--------+    ssh    +-----------+
| browser | <==========> | webssh | <=======> | ssh server|
+---------+   websocket  +--------+    ssh    +-----------+

要求

  • Python2.7/3.4+

快速启动

  1. 安装此应用程序,运行命令pip install webssh
  2. 启动web服务器,运行命令wssh
  3. 打开浏览器,导航到127.0.0.1:8888
  4. 输入你的数据,提交表格。

服务器选项

# start a http server with specified listen address and listen port
wssh --address='2.2.2.2' --port=8000# start a https server, certfile and keyfile must be passed
wssh --certfile='/path/to/cert.crt' --keyfile='/path/to/cert.key'# missing host key policy
wssh --policy=reject

# logging level
wssh --logging=debug

# log to file
wssh --log-file-prefix=main.log

# more options
wssh --help

浏览器控制台

// connect to your ssh server
wssh.connect(hostname,port,username,password,privatekey,passphrase,totp);// pass an object to wssh.connect
varopts={hostname:'hostname',port:'port',username:'username',password:'password',privatekey:'the private key text',passphrase:'passphrase',totp:'totp'};wssh.connect(opts);// without an argument, wssh will use the form data to connect
wssh.connect();// set a new encoding for client to use
wssh.set_encoding(encoding);// reset encoding to use the default one
wssh.reset_encoding();// send a command to the server
wssh.send('ls -l');

自定义字体

自定义字体系列用法示例:

<style>@font-face{font-family:'font-name';src:url('static/css/fonts/your-favorite-font');}body{font-family:'font-name';}</style>

url参数

支持按url(查询或片段)传递参数,如下所示 示例:

传递表单数据(密码必须以base64编码,privateKey不能 支持)

http://localhost:8888/?hostname=xx&username=yy&password=str_base64_encoded

传递终端背景色

http://localhost:8888/#bgcolor=green

传递用户定义的标题

http://localhost:8888/?title=my-ssh-server

传递编码

http://localhost:8888/#encoding=gbk

传递登录后立即执行的命令

http://localhost:8888/?command=pwd

使用Docker

启动应用程序

docker-compose up

关闭应用程序

docker-compose down

测试

要求

pip install pytest pytest-cov codecov flake8 mock

使用unittest运行所有测试

python -m unittest discover tests

使用pytest运行所有测试

python -m pytest tests

展开

在nginx服务器后面运行

wssh --address='127.0.0.1' --port=8888 --policy=reject
# Nginx config example
location/{proxy_passhttp://127.0.0.1:8888;proxy_http_version1.1;proxy_read_timeout300;proxy_set_headerUpgrade$http_upgrade;proxy_set_headerConnection"upgrade";proxy_set_headerHost$http_host;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Real-PORT$remote_port;}

作为独立服务器运行

wssh --port=8080 --sslport=4433 --certfile='cert.crt' --keyfile='cert.key' --xheaders=False --policy=reject

提示

  • 对于您选择的任何部署选择,不要忘记启用 SSL协议。
  • 默认情况下,来自公共网络的纯http请求将是 重定向或被阻止和被重定向优先于 被封锁了。
  • 尝试将拒绝策略与 你的已知主机,这将防止中间人 攻击。其思想是检查系统主机密钥 文件(“~/.ssh/known_hosts”)和应用程序主机密钥 如果ssh服务器的主机名不是 找到或密钥不匹配,连接将中止。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java RMI客户端访问被拒绝   java让JavaFX事件监听器与我的方法对话   java与xml spring配置相关   java当我在字符串中插入这个XML Soap请求时,为什么Eclipse会给我一个错误?   音频音频合成   java创建了一个Tic-Tac-Toe应用程序,我有一个bug,它每次在同一个正方形上声明一个平局   java为返回的字符串值设置参数   Java中的ClassFormatError   java在启动后更改Spring云配置服务器uri   用Java中的自定义类替换默认字符串类   java junit测试套件:ClassNotFoundException   java自定义对象集包含相同的对象   通过关系查找的java Spring数据CRUDepository   java将数据存储到aerospike中   java使用itextpdf将添加内容的pdf转换为安卓中的位图   java正在遍历队列的concurrentHashMap,以查看是否所有队列都是空的,而其他线程可能会添加到队列中   java Hibernate:未找到本机查询异常   java Mockito准确地验证所有参数   java我可以在它自己的类中声明一个对象吗?