weh shell高大上?一文教你实现

骚年 运维少年

weh shell高大上?一文教你实现


一、概述

在很多堡垒机、IT审计等平台中,基本上都会带上一个web版的ssh,实现了用户能在web界面对服务器进行shell操作。又或者我们在防火墙后面不能使用这些工具访问远程系统,或者防火墙只允许HTTPS流量才能通过。那我们怎么才能对服务器进行操作呢?


二、shellinaboxd

是由Markus Gutschke开发的一款自由开源的基于Web的Ajax的终端模拟器。使用shellainbox不需要安装任何类似于 XShell 或 Putty 的通讯工具,也不用安装任何插件或第三方应用软件,你只需要有一个支持 JavaScript 和 CSS 的现代浏览器,通过Web浏览器提供了类似原生的 Shell 的外观和感受。shellinaboxd守护进程实现了一个Web服务器,能够侦听指定的端口。但是,这并不一定是一个安全的软件,我不建议在公网上将其暴露出来。

1) 安装shellinabox

本文以centos 7.5为例

  • 使用yum安装
[root@yunwsn /]# yum install shellinabox -yLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package shellinabox.x86_64 0:2.20-5.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved==================================================================================== Package               Arch             Version                Repository      Size====================================================================================Installing: shellinabox           x86_64           2.20-5.el7             epel           136 kTransaction Summary====================================================================================Install  1 PackageTotal download size: 136 kInstalled size: 503 kDownloading packages:shellinabox-2.20-5.el7.x86_64.rpm                            | 136 kB  00:00:00     Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Installing : shellinabox-2.20-5.el7.x86_64                                    1/1   Verifying  : shellinabox-2.20-5.el7.x86_64                                    1/1 Installed:  shellinabox.x86_64 0:2.20-5.el7                                                   Complete![root@yunwsn /]# 
  • 启动服务
[root@yunwsn /]# systemctl start shellinaboxd.service [root@yunwsn /]# systemctl status shellinaboxd.service ● shellinaboxd.service - Shell In A Box daemon   Loaded: loaded (/usr/lib/systemd/system/shellinaboxd.service; disabled; vendor preset: disabled)   Active: active (running) since Mon 2019-06-03 14:23:54 CST; 7s ago     Docs: man:shellinaboxd(1) Main PID: 30454 (shellinaboxd)   CGroup: /system.slice/shellinaboxd.service           ├─30454 /usr/sbin/shellinaboxd -u shellinabox -g shellinabox --cert=/v...           └─30455 /usr/sbin/shellinaboxd -u shellinabox -g shellinabox --cert=/v...
  • 查看端口
[root@yunwsn /]# netstat -natlpActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      876/sshd            tcp        0      0 0.0.0.0:4200            0.0.0.0:*               LISTEN      30454/shellinaboxd  

可以看到默认端口是4200

2) 使用shellainbox

  • 使用网页打开https://ip:4200(注意:一定是https打开)
  • 登录(注意,不支持root用户登录,只能使用普通用户登录)

3) 修改端口号

  • 修改配置文件,修改PORT即可
vi /etc/sysconfig/shellinaboxd# Basic optionsUSER=shellinaboxGROUP=shellinaboxCERTDIR=/var/lib/shellinaboxPORT=443OPTS="--disable-ssl-menu -s /:LOGIN"
  • 重启服务
systemctl restart shellinaboxd.service
  • 查看端口
tcp        0      0 10.104.145.137:443      116.21.13.32:39703      ESTABLISHED 31255/shellinaboxd 
©著作权归作者所有:来自51CTO博客作者mb5ffd6f0f39006的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. Xmind8 激活
  2. NMAP 使用
  3. kubernets中部署高可用nacos
  4. 计算机端口号的分类和测试方法
  5. linux系统中普通用户获取root权限
  6. Mac系统上查看端口占用和释放端口教程
  7. 对接一个新的项目或者新的工作
  8. 第13章 0225-PDO操作数据库技术,学习心得、笔记(员工管理系统(mysql
  9. Postgresql管理_创建数据库

随机推荐

  1. javascript相关小内容
  2. 将jQuery datepicker应用到多个实例
  3. 常见的面试题
  4. 是什么导致Meteor中的“模板未定义”?
  5. adobeindesign JavaScript XML:如何以编
  6. 从文本框值生成条形码图像
  7. 谷歌地图在角度指令中不起作用
  8. js金额数字格式化实现代码(三位加逗号处
  9. 另一个iframe中的iframe的onload函数
  10. JavaScript 中的函数介绍