GateOne 是一款使用 HTML5 技术编写的网页版 SSH 终端模拟器。基于现代的 HTML5 技术,无需任何浏览器插件、支持多个 SSH 进程、可以嵌入到其他任意应用程序中、支持使用 JavaScript,Python 甚至纯 CSS 编写的插件、支持 SSH 进程副本,打开多个进程而无需重复输入密码、 支持各种服务器端的日志功能,支持 Keberos-based 单点登录甚至活动目录、 支持操作日志记录,具有操作记录回放功能。
上图上半部分为默认的界面,点击上面的ssh连接图标后可以跳出下半部分让连接的操作,可以按上面的格式进行输入需要连接的主机。
一、安装
安装相关依赖
yum -y install python-tornado pip install futures pip install html5lib
注:依赖确认,可以通过git clone后,运行python run_gateone.py查看有什么报错一般就是缺什么包。
gateone安装
git clone https://github.com/liftoff/GateOne cd GateOne/ python setup.py install
默认安装完成后执行程序为/usr/bin/gateone,其会在systemctl 下产生相关服务。可以通过如下命令启动和配置开机自启动。
systemctl start gateone systemctl enable gateone
二、配置
使用gateone –help可以看下gateone支持的配置参数。其默认配置为/etc/gateone/conf.d/目录下(该目录下默认是空的,执行gateone启动后会生成三个文件):
[root@localhost conf.d]# ls 10server.conf 20authentication.conf 50terminal.conf [root@localhost conf.d]# pwd /etc/gateone/conf.d
其配置文件为json格式。
服务的默认配置是使用的https,可以通过将disable_ssl 设置为true关闭https(设置为http)。
url_prefix 默认为/,即https://IP:端口访问主机,如果需要和nginx进行整合,一般可以配置该配置,比如设置url_prefix值为”/gateone/”。
origins配置为指定允许连接的IP地址,当配置nginx反向代理时,需要将nginx的地址加入该地址中,不然在设置完url_prefix后,不设置该项会出现/ws 404的错误。
我使用的server.conf配置如下:
[root@localhost conf.d]# more 10server.conf // This is Gate One's main settings file. { // "gateone" server-wide settings fall under "*" "*": { "gateone": { // These settings apply to all of Gate One "address": "", "ca_certs": null, "cache_dir": "/tmp/gateone_cache", "certificate": "/etc/gateone/ssl/certificate.pem", "cookie_secret": "OGY5Nzk2NTY1NzIzNGI2ZDk3MmM3N2M4YTVlYzk3MDBmM", "debug": false, "disable_ssl": true, //关闭https "embedded": false, "enable_unix_socket": false, "gid": "0", "https_redirect": false, "js_init": "", "keyfile": "/etc/gateone/ssl/keyfile.pem", "locale": "en_US", "log_file_max_size": 100000000, "log_file_num_backups": 10, "log_file_prefix": "/var/log/gateone/gateone.log", "log_to_stderr": null, "logging": "info", "multiprocessing_workers": null, "origins": ["localhost", "127.0.0.1", "localhost.localdomain", "localhost4", "localhost4.localdomain4", "localhost6", "localhost6.localdomain6","www.361way.com"] , "pid_file": "/var/run/gateone.pid", "port": 10443, //修改默认端口 "session_dir": "/tmp/gateone", "session_timeout": "5d", "syslog_facility": "daemon", "uid": "0", "unix_socket_mode": "0600", "unix_socket_path": "/tmp/gateone.sock", "url_prefix": "/gate/", //配合nginx反向代理 "user_dir": "/var/lib/gateone/users", "user_logs_max_age": "30d" } } }
三、nginx反向代理
nginx反向代理配置如下:
location /gate/ { auth_basic "Private Property"; auth_basic_user_file /App/nginx/conf/.htpasswd_gateone; proxy_pass http://10.212.52.14:10443 ; proxy_redirect off; proxy_pass_header Server; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $http_address; proxy_set_header X-Scheme $scheme; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
其中认证文件使用htpasswd命令生成(httpd-tools包内):
htpasswd -c .htpasswd_gateone gateone
四、日志回放
logviewer.py 用于操作记录回放,
[root@localhost logs]# find / -name logviewer.py /tmp/GateOne/gateone/applications/terminal/logviewer.py /tmp/GateOne/build/lib/gateone/applications/terminal/logviewer.py /usr/lib/python2.7/site-packages/gateone-1.2.0-py2.7.egg/gateone/applications/terminal/logviewer.py
其对应的日志文件位置为:/var/lib/gateone/users/ANONYMOUS/logs 。该日志文件内容直接是使用more less这类命令是看不了的,需要使用logviewer.py + 文件名的方式查看,该命令执行后会回放之前的操作记录。