[Web远程wsshd]CentOS6.4搭建配置wssh
时间:2015-07-12 02:14 来源:linux.it.net.cn 作者:IT
wssh 是一个 SSH 到 WebSockets 的桥,可以让你通过 HTTP 调用远程服务器的 SHELL 命令。
wssh 可以让我们通过 HTTP 来调用远程的一个 shell,也就是说我们可以用浏览器来访问某个 Linux 服务器/虚拟机的终端(只要这个服务器上运行了 wsshd 服务器端)。wssh 客户端通过 ssh 帐号连接到 wsshd 服务器端。wssh 更多的是当作库来开发一些应用,比如开发云计算、虚拟机后台控制面板的虚拟机控制台等等。
下载并安装wssh:
$ git clone https://github.com/aluzzardi/wssh.git
$ cd wssh
$ sudo python setup.py install
启动:
[root@localhost ~]# wsshd
wsshd/0.1.0 running on 0.0.0.0:5000
上述是官方getHub上提供的基本安装启动方式。不过一般安装过程中多会出现很多问题,本人仅将安装过程中遇到的问题与解决方案在下文详细列出贡给位参考:
一、必备的安装软件
主要有:gcc python libevent-dev python-dev python-pip
安装方法:sudo yun install git gcc python libevent-dev python-dev
python-pip安装方式:
首先要安装 Setuptools
wget --no-check-certificate https://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
sudo sh ./setuptools-0.6c11-py2.6.egg
安装PIP
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-1.4.tar.gz
tar -zxvf ./pip-1.4.tar.gz
cd pip-1.4
sudo python setup.py install
二、安装wssh需要的各种Python库
主要有:gevent gevent-websocket paramiko flask
sudo pip install gevent gevent-websocket paramiko flask
按照上述步骤执行好之后,我们可以安装wssh,
Traceback (most recent call last):
File "/usr/bin/wsshd", line 5, in <module>
pkg_resources.run_script('wssh==0.1.0', 'wsshd')
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 489, in run_script
if insert:
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1207, in run_script
File "/usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd", line 63, in <module>
import argparse
ImportError: No module named argparse ##提示我们缺少argparse
接下来我们就按照提示安装确实的argparse:
######### 安装缺失的包 #########
[root@cloud003 wssh]# sudo pip install argparse
Downloading/unpacking argparse
You are installing an externally hosted file. Future versions of pip will default to disallowing externally hosted files.
Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded
Running setup.py egg_info for package argparse
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.orig' found anywhere in distribution
warning: no previously-included files matching '*.rej' found anywhere in distribution
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching 'env24'
no previously-included directories found matching 'env25'
no previously-included directories found matching 'env26'
no previously-included directories found matching 'env27'
Installing collected packages: argparse
Running setup.py install for argparse
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.orig' found anywhere in distribution
warning: no previously-included files matching '*.rej' found anywhere in distribution
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching 'env24'
no previously-included directories found matching 'env25'
no previously-included directories found matching 'env26'
no previously-included directories found matching 'env27'
Successfully installed argparse
Cleaning up...
########## 再次启动wsshd,还会有错吗? ##################
[root@cloud003 wssh]# wsshd
Traceback (most recent call last):
File "/usr/bin/wsshd", line 5, in <module>
pkg_resources.run_script('wssh==0.1.0', 'wsshd')
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 489, in run_script
if insert:
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1207, in run_script
File "/usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd", line 65, in <module>
from geventwebsocket import WebSocketHandler
ImportError: cannot import name WebSocketHandler
上述错误说明在65行有问题,解决方案如下:
[root@cloud003 wssh]# vi /usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd
#######修改第65行为:from geventwebsocket.handler import WebSocketHandler ########
[root@cloud003 wssh]# wsshd ####成功启动
wsshd/0.1.0 running on 0.0.0.0:5000
--------------------------------------------------------------------------------
DEBUG in wsshd [/usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd:27]:
(责任编辑:IT)
wssh 是一个 SSH 到 WebSockets 的桥,可以让你通过 HTTP 调用远程服务器的 SHELL 命令。 下载并安装wssh: $ git clone https://github.com/aluzzardi/wssh.git $ cd wssh $ sudo python setup.py install 启动: [root@localhost ~]# wsshd wsshd/0.1.0 running on 0.0.0.0:5000 上述是官方getHub上提供的基本安装启动方式。不过一般安装过程中多会出现很多问题,本人仅将安装过程中遇到的问题与解决方案在下文详细列出贡给位参考: 一、必备的安装软件 主要有:gcc python libevent-dev python-dev python-pip 安装方法:sudo yun install git gcc python libevent-dev python-dev python-pip安装方式: 首先要安装 Setuptools wget --no-check-certificate https://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg sudo sh ./setuptools-0.6c11-py2.6.egg 安装PIP wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-1.4.tar.gz tar -zxvf ./pip-1.4.tar.gz cd pip-1.4 sudo python setup.py install 二、安装wssh需要的各种Python库 主要有:gevent gevent-websocket paramiko flask sudo pip install gevent gevent-websocket paramiko flask 按照上述步骤执行好之后,我们可以安装wssh, Traceback (most recent call last): File "/usr/bin/wsshd", line 5, in <module> pkg_resources.run_script('wssh==0.1.0', 'wsshd') File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 489, in run_script if insert: File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1207, in run_script File "/usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd", line 63, in <module> import argparse ImportError: No module named argparse ##提示我们缺少argparse 接下来我们就按照提示安装确实的argparse: ######### 安装缺失的包 ######### [root@cloud003 wssh]# sudo pip install argparse Downloading/unpacking argparse You are installing an externally hosted file. Future versions of pip will default to disallowing externally hosted files. Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded Running setup.py egg_info for package argparse warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '*.orig' found anywhere in distribution warning: no previously-included files matching '*.rej' found anywhere in distribution no previously-included directories found matching 'doc/_build' no previously-included directories found matching 'env24' no previously-included directories found matching 'env25' no previously-included directories found matching 'env26' no previously-included directories found matching 'env27' Installing collected packages: argparse Running setup.py install for argparse warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '*.orig' found anywhere in distribution warning: no previously-included files matching '*.rej' found anywhere in distribution no previously-included directories found matching 'doc/_build' no previously-included directories found matching 'env24' no previously-included directories found matching 'env25' no previously-included directories found matching 'env26' no previously-included directories found matching 'env27' Successfully installed argparse Cleaning up... ########## 再次启动wsshd,还会有错吗? ################## [root@cloud003 wssh]# wsshd Traceback (most recent call last): File "/usr/bin/wsshd", line 5, in <module> pkg_resources.run_script('wssh==0.1.0', 'wsshd') File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 489, in run_script if insert: File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1207, in run_script File "/usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd", line 65, in <module> from geventwebsocket import WebSocketHandler ImportError: cannot import name WebSocketHandler 上述错误说明在65行有问题,解决方案如下: [root@cloud003 wssh]# vi /usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd #######修改第65行为:from geventwebsocket.handler import WebSocketHandler ######## [root@cloud003 wssh]# wsshd ####成功启动 wsshd/0.1.0 running on 0.0.0.0:5000 -------------------------------------------------------------------------------- DEBUG in wsshd [/usr/lib/python2.6/site-packages/wssh-0.1.0-py2.6.egg/EGG-INFO/scripts/wsshd:27]: (责任编辑:IT) |