Centos安装GateOne问题AttributeError: 'module' object has no attribute 'enable_pretty_logging'解决方案

前端之家收集整理的这篇文章主要介绍了Centos安装GateOne问题AttributeError: 'module' object has no attribute 'enable_pretty_logging'解决方案前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

需要的环境:
(1) Windows系统机器
(2) ssh工具Xshell软件
(3) centos虚拟机
参考安装和下载地址:
(1) http://liftoff.github.io/GateOne/About/prerequisites.html 官网
(2) http://www.90.vc/archives/1127 中文网站
(3) http://www.2cto.com/os/201411/349816.html 中文网站
安装pip
https://pip.pypa.io/en/latest/installing/#do-i-need-to-install-pip 官网

GateOne介绍

GateOne 是一款使用 HTML5 技术编写的网页版 SSH 终端模拟器。就是类似于Windows上远程ssh工具,例如Xshell等。
亮点有:
• 基于现代的 HTML5 技术,无需任何浏览器插件
支持多个 SSH 进程。
• 可以嵌入到其他任意应用程序中。
支持使用 JavaScript,Python 甚至纯 CSS 编写的插件
支持 SSH 进程副本,打开多个进程而无需重复输入密码。
支持各种服务器端的日志功能支持 Keberos-based 单点登录甚至活动目录。
以上参考:https://linuxtoy.org/archives/gateone.html 可以看到外网的介绍视屏。
官网上介绍说在CentOS下安装GateOne的先决条件是:
(1) Python 版本为2.6+和3.2+
(2) Tornado Framework 框架2.2+
(3) 如果Python是2.6版本的需要安装ordereddict module
(4) tornado kerberos等模块

安装过程

(1) 下载必要的源
epel-release-6-8.noarch.rpm源的下载和安装

  1. [root@localhost tools]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
  2. --2016-08-08 05:26:07-- http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
  3. Resolving dl.fedoraproject.org... 209.132.181.24,209.132.181.23,209.132.181.27,...
  4. Connecting to dl.fedoraproject.org|209.132.181.24|:80... connected.
  5. HTTP request sent,awaiting response... 200 OK
  6. Length: 14540 (14K) [application/x-rpm]
  7. Saving to: epel-release-6-8.noarch.rpm
  8.  
  9. 100%[===========================================>] 14,540 60.8K/s in 0.2s
  10.  
  11. 2016-08-08 05:26:08 (60.8 KB/s) - epel-release-6-8.noarch.rpm saved [14540/14540]
  12.  
  13. [root@localhost tools]# rpm -Uvh epel-release*rpm
  14. warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature,key ID 0608b895: NOKEY
  15. Preparing... ########################################### [100%]
  16. 1:epel-release ########################################### [100%]
  17. [root@localhost tools]# yum install epel-release
  18. Loaded plugins: fastestmirror
  19. Setting up Install Process
  20. Loading mirror speeds from cached hostfile
  21. epel/Metalink | 4.7 kB 00:00
  22. * base: mirrors.hust.edu.cn
  23. * epel: mirrors.neusoft.edu.cn
  24. * extras: mirrors.hust.edu.cn
  25. * updates: mirrors.hust.edu.cn
  26. base | 3.7 kB 00:00
  27. epel | 4.3 kB 00:00
  28. epel/primary_db | 5.9 MB 00:03
  29. extras | 3.4 kB 00:00
  30. updates | 3.4 kB 00:00
  31. updates/primary_db | 1.4 MB 00:01
  32. Package epel-release-6-8.noarch already installed and latest version
  33. Nothing to do
  34. [root@localhost tools]#

rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm源的下载和安装

  1. [root@localhost tools]# wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  2. --2016-08-08 05:31:39-- http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  3. Resolving apt.sw.be... 193.1.193.67
  4. Connecting to apt.sw.be|193.1.193.67|:80... connected.
  5. HTTP request sent,awaiting response... 200 OK
  6. Length: 12700 (12K) [application/x-redhat-package-manager]
  7. Saving to: rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  8.  
  9. 100%[===========================================>] 12,700 --.-K/s in 0s
  10.  
  11. 2016-08-08 05:31:41 (475 MB/s) - rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm saved [12700/12700]
  12.  
  13. [root@localhost tools]# rpm -Uvh rpmforge-release*rpm
  14. warning: rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 6b8d79e6: NOKEY
  15. Preparing... ########################################### [100%]
  16. 1:rpmforge-release ########################################### [100%]
  17. [root@localhost tools]#

(2) 安装依赖包

  1. [root@localhost tools]# yum install -y python python-pip gcc python-devel setuptool python-pam openssl openssl-devel wget make gcc-c++ patch pam_radius dtach pyOpenSSL perl

(3) 用pip命令安装tornado Kerberos

  1. [root@localhost tools]# pip install tornado kerberos

(4) 安装tornado

  1. [root@localhost tools]# wget https://github.com/downloads/liftoff/GateOne/tornado-2.4-1.noarch.rpm
  2. --2016-08-08 16:33:37-- https://github.com/downloads/liftoff/GateOne/tornado-2.4-1.noarch.rpm
  3. Resolving github.com... 192.30.253.113
  4. Connecting to github.com|192.30.253.113|:443... connected.
  5. HTTP request sent,awaiting response... 302 Found
  6. Location: https://cloud.github.com/downloads/liftoff/GateOne/tornado-2.4-1.noarch.rpm [following]
  7. --2016-08-08 16:33:39-- https://cloud.github.com/downloads/liftoff/GateOne/tornado-2.4-1.noarch.rpm
  8. Resolving cloud.github.com... 54.182.5.40,54.182.5.69,54.182.5.230,...
  9. Connecting to cloud.github.com|54.182.5.40|:443... connected.
  10. HTTP request sent,awaiting response... 200 OK
  11. Length: 577918 (564K) [audio/pn-realaudio-plugin]
  12. Saving to: tornado-2.4-1.noarch.rpm
  13.  
  14. 100%[===========================================>] 577,918 40.2K/s in 11s
  15.  
  16. 2016-08-08 16:33:55 (51.1 KB/s) - tornado-2.4-1.noarch.rpm saved [577918/577918]
  17.  
  18. [root@localhost tools]# ls
  19. epel-release-6-8.noarch.rpm tornado-2.4-1.noarch.rpm
  20. rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  21. [root@localhost tools]# rpm -ivh tornado-2.4-1.noarch.rpm
  22. Preparing... ########################################### [100%]
  23. 1:tornado ########################################### [100%]
  24. [root@localhost tools]#

(5) 安装Imaging

  1. [root@localhost tools]# rpm -ivh tornado-2.4-1.noarch.rpm
  2. Preparing... ########################################### [100%]
  3. 1:tornado ########################################### [100%]
  4. [root@localhost tools]# wget http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
  5. --2016-08-08 16:35:14-- http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
  6. Resolving effbot.org... 75.126.217.42
  7. Connecting to effbot.org|75.126.217.42|:80... connected.
  8. HTTP request sent,awaiting response... 200 OK
  9. Length: 498749 (487K) [application/octet-stream]
  10. Saving to: Imaging-1.1.7.tar.gz
  11.  
  12. 100%[===========================================>] 498,749 67.4K/s in 6.6s
  13.  
  14. 2016-08-08 16:35:25 (74.3 KB/s) - Imaging-1.1.7.tar.gz saved [498749/498749]
  15.  
  16. [root@localhost tools]# tar zxvf Imaging-1.1.7.tar.gz
  17. [root@localhost tools]# cd Imaging-1.1.7
  18. [root@localhost Imaging-1.1.7]# python setup.py install

(6) 安装ordereddict

  1. [root@localhost Imaging-1.1.7]# wget https://pypi.python.org/packages/source/o/ordereddict/ordereddict-1.1.tar.gz
  2. --2016-08-08 16:37:03-- https://pypi.python.org/packages/source/o/ordereddict/ordereddict-1.1.tar.gz
  3. Resolving pypi.python.org... 151.101.16.223,2a04:4e42:4::223
  4. Connecting to pypi.python.org|151.101.16.223|:443... connected.
  5. HTTP request sent,awaiting response... 200 OK
  6. Length: 2114 (2.1K) [application/octet-stream]
  7. Saving to: ordereddict-1.1.tar.gz
  8.  
  9. 100%[===========================================>] 2,114 --.-K/s in 0.001s
  10.  
  11. 2016-08-08 16:37:05 (2.28 MB/s) - ordereddict-1.1.tar.gz saved [2114/2114]
  12.  
  13. [root@localhost Imaging-1.1.7]# tar -zxvf ordereddict-1.1.tar.gz
  14. ordereddict-1.1/
  15. ordereddict-1.1/LICENSE
  16. ordereddict-1.1/ordereddict.py
  17. ordereddict-1.1/PKG-INFO
  18. ordereddict-1.1/setup.py
  19. [root@localhost Imaging-1.1.7]# cd ordereddict-1.1
  20. [root@localhost ordereddict-1.1]# python setup.py install
  21. running install
  22. running build
  23. running build_py
  24. creating build
  25. creating build/lib
  26. copying ordereddict.py -> build/lib
  27. running install_lib
  28. copying build/lib/ordereddict.py -> /usr/lib/python2.6/site-packages
  29. byte-compiling /usr/lib/python2.6/site-packages/ordereddict.py to ordereddict.pyc
  30. running install_egg_info
  31. Writing /usr/lib/python2.6/site-packages/ordereddict-1.1-py2.6.egg-info
  32. [root@localhost ordereddict-1.1]#

(7) 安装GateOne

  1. [root@localhost ~]# wget https://github.com/downloads/liftoff/GateOne/gateone-1.1-1.noarch.rpm
  2. --2016-08-08 17:03:56-- https://github.com/downloads/liftoff/GateOne/gateone-1.1-1.noarch.rpm
  3. Resolving github.com... 192.30.253.112
  4. Connecting to github.com|192.30.253.112|:443... connected.
  5. HTTP request sent,awaiting response... No data received.
  6. Retrying.
  7.  
  8. --2016-08-08 17:04:23-- (try: 2) https://github.com/downloads/liftoff/GateOne/gateone-1.1-1.noarch.rpm
  9. Connecting to github.com|192.30.253.112|:443... connected.
  10. HTTP request sent,awaiting response... 302 Found
  11. Location: https://cloud.github.com/downloads/liftoff/GateOne/gateone-1.1-1.noarch.rpm [following]
  12. --2016-08-08 17:04:25-- https://cloud.github.com/downloads/liftoff/GateOne/gateone-1.1-1.noarch.rpm
  13. Resolving cloud.github.com... 54.182.5.219,54.182.5.245,54.182.5.247,...
  14. Connecting to cloud.github.com|54.182.5.219|:443... Failed: Connection refused.
  15. Connecting to cloud.github.com|54.182.5.245|:443... Failed: Connection refused.
  16. Connecting to cloud.github.com|54.182.5.247|:443... connected.
  17. HTTP request sent,awaiting response... 200 OK
  18. Length: 11538671 (11M) [audio/pn-realaudio-plugin]
  19. Saving to: gateone-1.1-1.noarch.rpm.1
  20.  
  21. 100%[===========================================>] 11,538,671 21.1K/s in 9m 6s
  22.  
  23. 2016-08-08 17:14:16 (20.6 KB/s) - gateone-1.1-1.noarch.rpm.1 saved [11538671/11538671]
  24. [root@localhost tools]# rpm -ivh gateone-1.1-1.noarch.rpm
  25. Preparing... ########################################### [100%]
  26. 1:gateone ########################################### [100%]
  27. [root@localhost tools]#

(8) 第一次开启服务

  1. [root@localhost tools]# cd /opt/
  2. [root@localhost opt]# ls
  3. gateone
  4. [root@localhost opt]# cd gateone/
  5. [root@localhost gateone]# ls
  6. authpam.py gateone.py plugins static tests
  7. auth.py i18n README.rst templates utils.py
  8. babel_gateone.cfg LICENSE.txt remote_syslog.py terminal.py
  9. docs logviewer.py sso.py termio.py
  10. [root@localhost gateone]# ./gateone.py
  11. Traceback (most recent call last):
  12. File "./gateone.py",line 289,in <module>
  13. tornado.options.enable_pretty_logging()
  14. AttributeError: 'module' object has no attribute 'enable_pretty_logging'
  15. [root@localhost gateone]#

启动出现了问题,找了一下,原来是tornado版本不对

  1. [root@localhost gateone]# python -c "import tornado; print(tornado.version)"
  2. 4.4.1
  3. [root@localhost gateone]#

要求是2.4左右的才能运行GateOne的server

  1. [root@localhost ~]# wget https://pypi.python.org/packages/2d/9a/38e855094bd11cba89cd2a50a54c31019ef4a45785fe12be6aa9a7c633de/tornado-2.4.tar.gz#md5=c738af97c31dd70f41f6726cf0968941
  2. --2016-08-08 17:32:09-- https://pypi.python.org/packages/2d/9a/38e855094bd11cba89cd2a50a54c31019ef4a45785fe12be6aa9a7c633de/tornado-2.4.tar.gz
  3. Resolving pypi.python.org... 151.101.16.223,awaiting response... 200 OK
  4. Length: 347522 (339K) [application/octet-stream]
  5. Saving to: tornado-2.4.tar.gz
  6.  
  7. 100%[===========================================>] 347,522 8.51K/s in 34s
  8.  
  9. 2016-08-08 17:32:44 (9.92 KB/s) - tornado-2.4.tar.gz saved [347522/347522]
  10. [root@localhost ~]# tar zxvf tornado-2.4.tar.gz
  11. [root@localhost ~]# cd tornado-2.4
  12. [root@localhost tornado-2.4]# ls
  13. demos PKG-INFO runtests.sh setup.py tornado.egg-info
  14. MANIFEST.in README setup.cfg tornado
  15. [root@localhost tornado-2.4]# python setup.py build
  16. [root@localhost tornado-2.4]# python2 setup.py install
  17. [root@localhost tornado-2.4]# python -c "import tornado; print(tornado.version)"
  18. 2.4
  19. [root@localhost tornado-2.4]#

再次启动

  1. [root@localhost gateone]# pwd
  2. /opt/gateone
  3. [root@localhost gateone]# ls
  4. authpam.py gateone.py plugins static tests
  5. auth.py i18n README.rst templates utils.py
  6. babel_gateone.cfg LICENSE.txt remote_syslog.py terminal.py
  7. docs logviewer.py sso.py termio.py
  8. [root@localhost gateone]# ./gateone.py
  9. [I 160808 17:40:22 gateone:2748] /opt/gateone/server.conf not found or missing cookie_secret. A new one will be generated.
  10. [I 160808 17:40:22 gateone:2917] Connections to this server will be allowed from the following origins: 'http://localhost https://localhost http://127.0.0.1 https://127.0.0.1 https://localhost https://localhost.localdomain https://localhost4 https://localhost4.localdomain4 https://localhost.localdomain https://localhost6 https://localhost6.localdomain6 https://127.0.0.1 https://127.0.0.1'
  11. [I 160808 17:40:22 gateone:2957] No SSL private key found. One will be generated.
  12. [I 160808 17:40:22 gateone:2307] No authentication method configured. All users will be ANONYMOUS [I 160808 17:40:22 gateone:2404] Loaded plugins: bookmarks,convenience,example,help,logging,logging_plugin,mobile,notice,playback,ssh
  13. [I 160808 17:40:22 gateone:3054] Listening on https://*:443/
  14. [I 160808 17:40:22 gateone:3060] Process running with pid 3728
  15. ^C[I 160808 17:40:26 gateone:3084] Caught KeyboardInterrupt. Killing sessions...
  16. [I 160808 17:40:26 gateone:3088] pid file removed.
  17. [root@localhost gateone]#

(9) 配置文件
我们Ctrl + c,关闭服务器,然后配置一下配置文件

  1. [root@localhost gateone]# pwd
  2. /opt/gateone
  3. [root@localhost gateone]# vi server.conf
  4.  
  5. # -*- coding: utf-8 -*-
  6. locale = "en_US"
  7. pam_service = "login"
  8. syslog_facility = "daemon"
  9. syslog_host = None
  10. enable_unix_socket = False
  11. port = 443
  12. uid = "0"
  13. url_prefix = "/"
  14. user_dir = "/opt/gateone/users"
  15. dtach = True
  16. certificate = "certificate.pem"
  17. log_to_stderr = False
  18. session_logs_max_age = "30d"
  19. gid = "0"
  20. pid_file = "/var/run/gateone.pid"
  21. sso_realm = None
  22. cookie_secret = "YjM1NjZmNjhjZTY4NDcwZDljZjdhZTM5ZTJiMGRhNzI5Y"
  23. pam_realm = "localhost.localdomain"
  24. sso_service = "HTTP"
  25. https_redirect = False
  26. syslog_session_logging = False
  27. disable_ssl = False
  28. debug = False
  29. session_dir = "/tmp/gateone"
  30. auth = "none"
  31. address = ""
  32. api_timestamp_window = "30s"
  33. log_file_num_backups = 10
  34. logging = "info"
  35. embedded = False
  36. origins = "http://localhost;https://localhost;http://127.0.0.1;https://127.0.0.1;https://localhost;https://localhost.localdomain;https://localhost4;https://localhost4.localdomain4;https://localhost.localdomain;https://localhost6;https://localhost6.localdomain6;https://127.0.0.1;https://127.0.0.1"
  37. session_logging = True
  38. unix_socket_path = "/var/run/gateone.sock"
  39. ssl_auth = "none"
  40. log_file_max_size = 104857600
  41. session_timeout = "5d"
  42. command = "/opt/gateone/plugins/ssh/scripts/ssh_connect.py -S '/tmp/gateone/%SESSION%/%SHORT_SOCKET%' --sshfp -a '-oUserKnownHostsFile=%USERDIR%/%USER%/ssh/known_hosts'"
  43. ca_certs = None
  44. js_init = ""
  45. keyfile = "keyfile.pem"
  46. log_file_prefix = "/opt/gateone/logs/webserver.log"

我们一般修改是的允许访问的IP地址,或者是地址段

  1. origins = " https://192.168.220.145;http://192.168.220.145;https://192.168.60.216; https://192.168.60.216;http://localhost;https://localhost;http://127.0.0.1;https://127.0.0.1;https://localhost;https://localhost.localdomain;https://localhost4;https://localhost4.localdomain4;https://localhost.localdomain;https://localhost6;https://localhost6.localdomain6;https://127.0.0.1;https://127.0.0.1"

(10) 启动访问

  1. [root@localhost gateone]# ./gateone.py
  2. [I 160809 04:30:16 gateone:2917] Connections to this server will be allowed from the following origins: 'https://192.168.220.145 http://192.168.220.145 https://192.168.60.216 http://192.168.60.216 http://localhost https://localhost http://127.0.0.1 https://127.0.0.1 https://localhost https://localhost.localdomain https://localhost4 https://localhost4.localdomain4 https://localhost.localdomain https://localhost6 https://localhost6.localdomain6 https://127.0.0.1 https://127.0.0.1'
  3. [I 160809 04:30:16 gateone:2307] No authentication method configured. All users will be ANONYMOUS [I 160809 04:30:16 gateone:2404] Loaded plugins: bookmarks,ssh
  4. [I 160809 04:30:16 gateone:3054] Listening on https://*:443/
  5. [I 160809 04:30:16 gateone:3060] Process running with pid 5377

记得关防火墙和Selinux哦!

  1. [root@localhost opt]# /etc/init.d/iptables status
  2. Table: filter
  3. Chain INPUT (policy ACCEPT)
  4. num target prot opt source destination
  5. 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
  6. 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
  7. 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
  8. 4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
  9. 5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
  10.  
  11. Chain FORWARD (policy ACCEPT)
  12. num target prot opt source destination
  13. 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
  14.  
  15. Chain OUTPUT (policy ACCEPT)
  16. num target prot opt source destination
  17.  
  18. [root@localhost opt]# /etc/init.d/iptables stop
  19. iptables: Setting chains to policy ACCEPT: filter [ OK ]
  20. iptables: Flushing firewall rules: [ OK ]
  21. iptables: Unloading modules: [ OK ]
  22. [root@localhost opt]# chkconfig iptables off
  23.  
  24. [root@localhost opt]# getenforce
  25. Enforcing
  26. [root@localhost opt]# setenforce 0
  27. [root@localhost opt]# vi /etc/selinux/config
  28. SELINUX=disabled

本地Windows访问:
最好使用火狐浏览器、Google浏览器,在网址栏输入:https://192.168.220.145, ip地址是你的GateOne机器的地址。第一次登录需要添加例外,允许我们的远程主机访问
第一次连接需要证书,我们添加例外,然后将证书添加到网页中,然后确认登录即可。
(11) 登录操作
第一次登录需要登录我们的远程主机,输入ip,端口,登录用户名,密码,即可进行操作。
后台显示效果

  1. [root@localhost gateone]# ./gateone.py
  2. [I 160809 04:30:16 gateone:2917] Connections to this server will be allowed from the following origins: 'https://192.168.220.145 http://192.168.220.145 https://192.168.60.216 http://192.168.60.216 http://localhost https://localhost http://127.0.0.1 https://127.0.0.1 https://localhost https://localhost.localdomain https://localhost4 https://localhost4.localdomain4 https://localhost.localdomain https://localhost6 https://localhost6.localdomain6 https://127.0.0.1 https://127.0.0.1'
  3. [I 160809 04:30:16 gateone:2307] No authentication method configured. All users will be ANONYMOUS [I 160809 04:30:16 gateone:2404] Loaded plugins: bookmarks,ssh
  4. [I 160809 04:30:16 gateone:3054] Listening on https://*:443/
  5. [I 160809 04:30:16 gateone:3060] Process running with pid 5377
  6. [I 160809 04:30:19 web:1462] 304 GET / (192.168.220.1) 3.91ms
  7. [I 160809 04:30:19 web:1462] 304 GET /combined_js (192.168.220.1) 3.50ms
  8. [I 160809 04:30:19 web:1462] 304 GET /auth?check=True (192.168.220.1) 0.86ms
  9. [I 160809 04:30:19 gateone:1063] WebSocket opened (ANONYMOUS).
  10. [I 160809 04:30:21 web:1462] 200 GET /static/ubuntumono-normal.woff (192.168.220.1) 6.98ms
  11. [I 160809 04:30:50 web:1462] 200 GET /static/ubuntumono-bold.woff (192.168.220.1) 3.26ms

详细文档请点击此处下载

@H_502_2040@

猜你在找的CentOS相关文章