欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  新闻

shell客户端连接不上(安卓shell终端工具使用)

程序员文章站 2022-06-16 12:56:57
linux shell web超级终端工具shellinaboxshell是linux内核应用程序,是指“为使用者提供操作界面”的软件,也是命令解析器,它类似于windows操作系统dos下的cmd....

linux shell web超级终端工具shellinabox

shell是linux内核应用程序,是指“为使用者提供操作界面”的软件,也是命令解析器,它类似于windows操作系统dos下的cmd.exe应用程序。它接收用户命令,然后调用相应的应用程序,用户一般管理linux服务器都是习惯用putty、xshell、securecrt、secure shell等客户端端工具,但是使用这些客户端都是需要在本地安装后才能使用,如果换其它电脑也是需要重新安装,这样非常使用起来非常麻烦,所以,我们今天就来介绍一块非常方便的shell客户端工具,使用系统自带的浏览器来管理linux服务终端,是一款能随时在任何终端上面管理,这一款运行在linux下面的工具 shellinabox,只需要在linux服务器上面安装并配置好shellinabox。

shellinabox是由markus gutschke创建的基于web的终端模拟器。它具有内置的shell web服务端,在指定端口上作为基于web的ssh客户端运行,并提示您使用任何支持ajax/javascript和css的浏览器远程访问和控制linux server ssh shell,而无需任何其他浏览器插件,使用非常方便,不过安装和配置是需要有点点linux基础,如果觉得自己完全不懂linux,可以建议去购买《linux就该这么学》这本教程,非常适合初学者入门,或者去此教程的官网查看详细的资料,直接在百度输入此书名就可以直接进入官网。

shellinbox是一款在linux服务器下有一个内建的web server作为基本的web ssh client,允许你通过指定的端口访问linux服务器的ssh shell,只要你的浏览器支持ajax/js/css就可以访问,不过现在主流的操作系统自带的浏览器都支持,shellinabox是一款开源的轻量级软件,在安装shellinabox之前要确定linux服务端是否安装了openssl库;debian和ubuntu官方还提供有deb安装包,而centos也有rpm包,也可以通过yum源安装,安装及配置也比较简单,下面我们来详细的安装和配置shellinabox。

一、在rhel、 centos系统上面安装及配置步骤如下

# yum install openssl shellinabox

loaded plugins: fastestmirror

determining fastest mirrors

epel/x86_64/metalink | 9.2 kb 00:00:00

* base: mirrors.aliyun.com

* epel: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

base | 3.6 kb 00:00:00

epel | 3.2 kb 00:00:00

extras | 3.4 kb 00:00:00

updates | 3.4 kb 00:00:00

(1/6): extras/7/x86_64/primary_db | 156 kb 00:00:00

(2/6): base/7/x86_64/group_gz | 166 kb 00:00:01

(3/6): epel/x86_64/updateinfo | 940 kb 00:00:08

(4/6): updates/7/x86_64/primary_db | 1.3 mb 00:00:10

(5/6): epel/x86_64/primary | 3.6 mb 00:00:21

(6/6): base/7/x86_64/primary_db | 6.0 mb 00:00:26

epel 12745/12745

resolving dependencies

–> running transaction check

—> package openssl.x86_64 1:1.0.2k-12.el7 will be updated

—> package openssl.x86_64 1:1.0.2k-16.el7 will be an update

–> processing dependency: openssl-libs(x86-64) = 1:1.0.2k-16.el7 for package: 1:openssl-1.0.2k-16.el7.x86_64

—> package shellinabox.x86_64 0:2.20-5.el7 will be installed

–> running transaction check

—> package openssl-libs.x86_64 1:1.0.2k-12.el7 will be updated

–> processing dependency: openssl-libs(x86-64) = 1:1.0.2k-12.el7 for package: 1:openssl-devel-1.0.2k-12.el7.x86_64

—> package openssl-libs.x86_64 1:1.0.2k-16.el7 will be an update

–> running transaction check

—> package openssl-devel.x86_64 1:1.0.2k-12.el7 will be updated

—> package openssl-devel.x86_64 1:1.0.2k-16.el7 will be an update

–> finished dependency resolution

dependencies resolved

======================================================================================

package arch version repository size

======================================================================================

installing:

shellinabox x86_64 2.20-5.el7 epel 136 k

updating:

openssl x86_64 1:1.0.2k-16.el7 base 493 k

updating for dependencies:

openssl-devel x86_64 1:1.0.2k-16.el7 base 1.5 m

openssl-libs x86_64 1:1.0.2k-16.el7 base 1.2 m

transaction summary

======================================================================================

install 1 package

upgrade 1 package (+2 dependent packages)

total download size: 3.3 m

is this ok [y/d/n]:y

downloading packages:

no presto metadata available for base

(1/4): openssl-1.0.2k-16.el7.x86_64.rpm | 493 kb 00:00:01

(2/4): shellinabox-2.20-5.el7.x86_64.rpm | 136 kb 00:00:01

(3/4): openssl-devel-1.0.2k-16.el7.x86_64.rpm | 1.5 mb 00:00:05

(4/4): openssl-libs-1.0.2k-16.el7.x86_64.rpm | 1.2 mb 00:00:05

———————————————————————————————————————–

total 469 kb/s | 3.3 mb 00:00:07

running transaction check

running transaction test

transaction test succeeded

running transaction

updating : 1:openssl-libs-1.0.2k-16.el7.x86_64 1/7

updating : 1:openssl-1.0.2k-16.el7.x86_64 2/7

installing : shellinabox-2.20-5.el7.x86_64 3/7

updating : 1:openssl-devel-1.0.2k-16.el7.x86_64 4/7

cleanup : 1:openssl-devel-1.0.2k-12.el7.x86_64 5/7

cleanup : 1:openssl-1.0.2k-12.el7.x86_64 6/7

cleanup : 1:openssl-libs-1.0.2k-12.el7.x86_64 7/7

verifying : 1:openssl-libs-1.0.2k-16.el7.x86_64 1/7

verifying : 1:openssl-devel-1.0.2k-16.el7.x86_64 2/7

verifying : shellinabox-2.20-5.el7.x86_64 3/7

verifying : 1:openssl-1.0.2k-16.el7.x86_64 4/7

verifying : 1:openssl-devel-1.0.2k-12.el7.x86_64 5/7

verifying : 1:openssl-1.0.2k-12.el7.x86_64 6/7

verifying : 1:openssl-libs-1.0.2k-12.el7.x86_64 7/7

installed:

shellinabox.x86_64 0:2.20-5.el7

updated:

openssl.x86_64 1:1.0.2k-16.el7

dependency updated:

openssl-devel.x86_64 1:1.0.2k-16.el7 openssl-libs.x86_64 1:1.0.2k-16.el7

complete!

二、配置shellinaboxd

192.168.3.160是ssh服务器ip地址,

# vim /etc/sysconfig/shellinaboxd

# tcp port that shellinboxd’s webserver listens on

port=6175

# specify the ip address of a destination ssh server

opts=”-s /:ssh:192.168.3.160″ #(https协议)

#opts=”-t -s /:ssh:192.168.3.160″ #(http协议)

# if you want to restrict access to shellinaboxd from localhost only

#下面配置是仅主机访问,其它主机不能访问

#opts=”-s /:ssh:192.168.3.160 –localhost-only”

shellinaboxd默认端口是:4200,我这里修改为6175。

shellinaboxd常用参数使用的帮助手册

# shellinaboxd –help

list of command line options:

-b, –background[=pidfile] run in background

-c, –cert=certdir set certificate dir (default: $pwd)

–cert-fd=fd set certificate file from fd

–css=file attach contents to css style sheet

–cgi[=portmin-portmax] run as cgi

-d, –debug enable debug mode

-f, –static-file=url:file serve static file from url path

-g, –group=gid switch to this group (default: nobody)

-h, –help print this message

–linkify=[none|normal|aggressive] default is “normal”

–localhost-only only listen on 127.0.0.1

–no-beep suppress all audio output

-n, –numeric do not resolve hostnames

-m, –messages-origin=origin allow iframe message passing from origin

–pidfile=pidfile publish pid of daemon process

-p, –port=port select a port (default: 4200)

-s, –service=service define one or more services

-t, –disable-ssl disable transparent ssl support

–disable-ssl-menu disallow changing transport mode

–disable-utmp-logging disable logging to utmp and wtmp

-q, –quiet turn off all messages

–unixdomain-only=path:user:group:chmod listen on unix socket

-u, –user=uid switch to this user (default: nobody)

–user-css=styles defines user-selectable css options

-v, –verbose enable logging messages

–version prints version information

–disable-peer-check disable peer check on a session

三、启动、停止、自启动服务

centos 6

# service shellinaboxd start //启动服务

# service shellinaboxd stop //停止服务

# service shellinaboxd restart //重启服务

# chkconfig shellinaboxd on //自启服务

centos 7

# systemctl start shellinaboxd.service

# systemctl stop shellinaboxd.service

# systemctl restart shellinaboxd.service

# systemctl enable shellinaboxd.service

强制关闭 shellinaboxd

查找到 shellinaboxd 的进程 pid ,kill 即可

# ps -aux|grep shellinaboxd | grep -v grep | awk ‘{print $1}’

也可在启动时加上 -p 参数,将进程 pid 保存到指定的文件中,需要关闭时读取它并进行 kill

四、查看服务状态

# netstat -nap | grep shellinabox

tcp 0 0 0.0.0.0:6175 0.0.0.0:* listen 118916/shellinaboxd

shell客户端连接不上(安卓shell终端工具使用)

默认60s不登录自动断开

shell客户端连接不上(安卓shell终端工具使用)

登录成功

shell客户端连接不上(安卓shell终端工具使用)

退出web shell终端:

shell客户端连接不上(安卓shell终端工具使用)