shellinabox基于web浏览器的终端模拟器

1. Shellinabox介绍

Shellinabox 是一个利用 Ajax 技术构建的基于 Web 浏览器的远程终端模拟器,也就是说安装了该软件之后,服务器端不需要开启 ssh服务,通过 Web 浏览器就可以对远程主机进行操作,但是你的web浏览器需要支持AJAX/Javascript和CSS,因此可以用http://localhost:4200来登录到你的系统,并且默认情况下启用了SSL/TLS证书,需要用https://localhost:4200来登录。

默认情况下shellinabox使用的是TCP协议的4200端口,因此如果你的系统启用了防火墙的话,请放行4200端口。

2. Shellinabox安装和配置

2.1 shellinabox的安装

shellinabox软件包有源码包和rpm包,最简单的方式就是通过rpm包进行安装。

源码包:http://shellinabox.googlecode.com/files/shellinabox-2.10.tar.gz

rpm包:

http://pkgs.org/centos-6/epel-x86_64/shellinabox-2.14-24.git88822c1.el6.x86_64.rpm.html

2.1.2 源码包安装

解压:

[root@server2 software]#tar -zxvf shellinabox-2.10.tar.gz

进入到解压目录,编译和安装:

[root@server2software]# cd shellinabox-2.10

[root@server2shellinabox-2.10]# ./configure && make && make install

在编译的时候还可以使用--prefix指定安装路径。

如:

./configure  --prefix=/usr/local/shellinabox

则安装时将会安装在/usr/local/shellinabox目录下,如果不指定的话,则默认会安装到/usr/local/bin目录下

默认情况下/etc/sysconfig/shellinaboxd的内容如下:

 1 [root@server1 ~]#more /etc/sysconfig/shellinaboxd
 2 # Shell in a boxdaemon configuration
 3 # For details seeshellinaboxd man page
 4 # Basic options
 5 USER=shellinabox
 6 GROUP=shellinabox
 7 CERTDIR=/var/lib/shellinabox
 8 PORT=4200
 9 OPTS="--disable-ssl-menu-s /:LOGIN"
10 # Additionalexamples with custom options:
11 # Fancyconfiguration with right-click menu choice for black-on-white:
12 #OPTS="--user-css Normal:+black-on-white.css,Reverse:-white-on-black.css--disable-ssl-menu -s /:LOGIN"
13 # Simpleconfiguration for running it as an SSH console with SSL disabled:
14 # OPTS="-t -s/:SSH:host.example.com"
15 [root@server1 ~]#

注释:

USER和GROUP:指定以哪个用户和组启动该服务。

CERTDIR:指定存放SSL证书的目录。

PORT:指定shellinaboxd服务的监听端口。默认为4200.

OPTS:设置一些其他的参数。

常用的opts如下:

-t:关闭SSL/TLS的支持。也就是不需要使用HTTPS连接,可以直接用http连接。

服务的启动与停止:

/etc/init.d/shellinaboxd  start
/etc/init.d/shellinaboxd  restart
/etc/init.d/shellinaboxd  stop

观察服务监听的端口:

[root@server1 ~]#netstat -tnlp | grep shellinabox

tcp        0     0 0.0.0.0:4200               0.0.0.0:*                   LISTEN      22455/shellinaboxd  

[root@server1 ~]#

设置服务的开机自动启动:

[root@server1 ~]#chkconfig shellinaboxd --level 35 on

[root@server1 ~]#chkconfig --list | grep shellinaboxd

shellinaboxd    0:off  1:off   2:off   3:on   4:on    5:on    6:off

[root@server1 ~]#

2.2.2 采用源码包安装时启动服务的指令

当采用源码包安装shellinabox时,启动服务的方式如下:

<安装路径>/bin/shellinaboxd   选项

常用的选项如下:

-b:在后台运行该服务

-u:指定运行该服务的用户,默认为nobody

-g:指定运行该服务的组,默认为nobody

-p:指定shellinaboxd的监听端口

-t:表示关闭SSL/TLS的支持。

-c:指定存放SSL证书的目录。

启动服务:

/usr/local/bin/shellinaboxd-b -t -u root

观察服务监听的端口:

[root@server2 bin]#netstat -tunlp | grep shellinabox

tcp        0     0 0.0.0.0:4200               0.0.0.0:*                  LISTEN      6765/shellinaboxd  

[root@server2 bin]#

停止服务:

killall -9 shellinaboxd

设置服务的开机自动启动:

编辑/etc/rc.d/rc.local,增加如下内容:

/usr/local/bin/shellinaboxd-b -t -u root -g root

至此,使用10.16.59.100:4200访问,若访问成功,则表示安装已经成功

原文地址:https://www.cnblogs.com/shangzekai/p/5213904.html