Web版SSH GateOne
GateOne 是一款使用 HTML5 技术编写的网页版 SSH 终端模拟器。基于现代的 HTML5 技术,无需任何浏览器插件、支持多个 SSH 进程、可以嵌入到其他任意应用程序中、支持使用 JavaScript,Python 甚至纯 CSS 编写的插件、支持 SSH 进程副本,打开多个进程而无需重复输入密码、 支持各种服务器端的日志功能,支持 Keberos-based 单点登录甚至活动目录、 支持操作日志记录,具有操作记录回放功能。
wssh 是基于 paramiko 模块的,但是通过 paramiko 模块访问 vi , vim , nano 等软件会存在问题。而 gateone 基本上已经满足了需要,效果是非常不错的。
GateOne 的部署
首先下载 GateOne 的源码:
在 https://github.com/liftoff/GateOne/downloads 中 下载 gateone-1.1.tar.gz 。
直接下载地址为:
https://github.com/downloads/liftoff/GateOne/gateone-1.1.tar.gz
- 1.解压安装包
1 | cd GateOne |
- 2.依赖环境的搭建
在线安装及安装依赖
1 | yum -y install epel-release |
安装PIP
yum install python-pip
yum install python-imaging
升级PIP
pip install --upgrade pip
pip install pyopenssl
pip install ordereddict
# 目前 GateOne 貌似对 tornado 的版本敏感,所以选择此版本
pip install tornado==2.4.1
离线安装,安装时保存离线包安装PIP,离线安装无需此步骤
yum -y install epel-release python-pip python-imaging --downloadonly --downloaddir=./
下载模块及依赖,离线安装无需此步骤
pip download pyopenssl ordereddict tornado==2.4.1
离线安装
将离线包及依赖放在服务器内执行
rpm -ivh *.rpm
pip install --no-index --find-links=./ pyopenssl ordereddict tornado==2.4.1
确保在 GateOne 目录内,安装 GateOne
python setup.py install
- 3.修改配置文件
先执行一下 gateone.py,会生成 server.conf 文件
cd gateone
./gateone.py
此时应该已经生成 server.conf 文件,修改下列重要项
vi server.conf
# -*- coding: utf-8 -*-
locale = "en_US"
pam_service = "login"
syslog_facility = "daemon"
syslog_host = None
enable_unix_socket = False
port = 9000 # 修改端口
uid = "0"
url_prefix = "/gate" # 要和Nginx设置一致
user_dir = "/opt/gateone/users"
dtach = True
certificate = "certificate.pem"
log_to_stderr = False
session_logs_max_age = "30d"
gid = "0"
pid_file = "/var/run/gateone.pid"
sso_realm = None
cookie_secret = "YTNkZWFhODQyYmY5NDFiODk5MmUwMjQ0NzIxMjliMjIyN"
pam_realm = "ubuntu-host"
sso_service = "HTTP"
https_redirect = False
syslog_session_logging = False
disable_ssl = True # 修改为true, 关闭https
debug = False
session_dir = "/tmp/gateone"
auth = "none"
address = ""
api_timestamp_window = "30s"
log_file_num_backups = 10
logging = "info"
embedded = False
# 对应的 origin,这里用 ; 分隔,注意其中的地址,关系到后面的访问
origins = "http://192.168.137.11:9000;http://192.168.3.35:80/gate;http://192.168.137.11:9000/gate"
session_logging = True
unix_socket_path = "/var/run/gateone.sock"
...
配置文件说明
- origins 登录的地址
- address改为”127.0.0.1”,这样外网不能直接访问GateOne,只能通过Nginx转发
- disable_ssl设为True,表示不用GateOne自带的证书
- port改为一个未占用的端口,要和Nginx设置一致
- url_prefix改为”/gateone/“,要和Nginx设置一致
后台启动
nohup python ./gateone.py >gateone.log &
打开浏览器,访问
https://yourip:端口
会提示输入对应的用户名和密码。
- 5.加入到 init.d,启动 GateOne
/etc/init.d/gateone restart
# * Stopping Gate One daemon gateone.py [ OK ]
# * Starting Gate One daemon gateone.py [ OK ]
# 配置nginx
# 配置文件内添加,注意添加位置
# 其中的location和proxy_pass中的端口,要和GateOne中的设置一致
# gateone
http{
upstream gateone {
server 192.168.137.11:80 weight=4;
server 192.168.137.13:9000 weight=2;
}
server {
listen 9000; # 端口
server_name 192.168.3.35; # 地址或者域名
#charset koi8-r;
charset utf-8;
location /gate/ {
proxy_pass http://gateone;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
}
}
}
设置好后,重启Nginx和GateOne,然后在浏览器输入http://IP/gate/ 就能使用了