Docker 配置WebSSH

article/2025/10/2 17:41:39

1、基于DockerHub Centos镜像

docker pull centos:centos7

2、 Centos镜像存在的一个自身问题:启动后的容器内部无法使用systemctl命令

        Failed to get D-Bus connection: Operation not permitted

## docker run -dit eeb6ee3f44bd /bin/bash
## 切勿忘记宿主机防火墙开放8889 2200端口
docker run -dit -p 8889:8888 -p 2200:22 --restart=always --privileged --name t2 centos:centos7 init

3、在基础镜像中安装基础服务

(1)安装sshd、httpd、firewalld服务

yum install -y openssh openssh-server openssh-client
yum install httpd
yum install firewalld firewall-config

(2) 启动服务后并加入开机自启

## 启动
systemctl start sshd
systemctl start httpd
systemctl start firewalld
## 开机自启
systemctl enable sshd
systemctl enable httpd
systemctl enable firewalld

(3)针对于httpd服务

localhost.localdomain httpd[1953]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

vi /etc/httpd/conf/httpd.conf 加入一句:ServerName localhost:80
systemctl restart httpd

(4)针对于firewalld服务

WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider disabling it now

vi /etc/firewalld/firewalld.conf
AllowZoneDrifting=yes ====》》AllowZoneDrifting=no
systemctl restart firewalld

(5)开放端口

firewall-cmd --permanent --add-port=8888/tcp
firewall-cmd --reload
firewall-cmd --list-all

(6)设置默认初始密码:passwd root

 4、在基础镜像中配置WebSSH

(1)安装python3

yum install python3-pip

(2)安装WebSSH

##### pip3 install webssh
##### pip3 报错:Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-xxx/xxx/ 
##### https://www.modb.pro/db/81767

 针对以上报错的解决方案:

### 升级setuptools
pip3 install --upgrade setuptools -i https://mirrors.aliyun.com/pypi/simple/
### 升级pip工具:https://www.cnblogs.com/rychh/p/16206842.html
pip3 --default-timeout=1000 install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/

 额外针对于以下告警的处理可选择性处理:

### WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
### https://blog.csdn.net/m0_58782029/article/details/129049587

进行安装:

pip3 --default-timeout=1000 install webssh -i https://mirrors.aliyun.com/pypi/simple/

5、后台启动并指定webssh服务的日志目录

wssh --log-file-prefix=/data/webssh/wssh.log --timeout=500 --fbidhttp=false &

 6、加入开机自启

vi /etc/rc.local
wssh --log-file-prefix=/data/webssh/wssh.log --timeout=500 --fbidhttp=false &
chmod 777 /etc/rc.local

 7、制作最终镜像并在迁移后使用 

1、打包正在运行的容器为 image
docker commit eeb6ee3f44bd webssh:dev
2、保存image到文件
docker save -o webssh_dev.tar webssh:dev
3、使用已保存的image文件
docker load --input webssh_dev.tar

 8、页面访问

访问方式(1)如图:

 访问方式(2)

## password需要进行base64加密
http://ip:8889?hostname=ip&username=root&password=cm9vdA==&port=2200

备注:

## 查看容器启动日志
[vagrant@localhost images]$ sudo docker inspect --format '{{.LogPath}}' 21431ff039e7
/data/docker/containers/21431ff039e768753702d64cb01b1a75bb250c2c587b0f3396dd30b548a62850/21431ff039e768753702d64cb01b1a75bb250c2c587b0f3396dd30b548a62850-json.log

http://chatgpt.dhexx.cn/article/drY4lRdu.shtml

相关文章

什么是Webshell?

一、什么是Webshell? 顾名思义,“web”的含义是显然需要服务器开放web服务,“shell”的含义是取得对服务器某种程度上操作权限。webshell常常被称为入侵者通过网站端口对网站服务器的某种程度上操作的权限。由于webshell其大多是以动态脚本的…

Flask框架:运用SocketIO实现WebSSH

Flask 框架中如果想要实现WebSocket功能有许多种方式,运用SocketIO库来实现无疑是最简单的一种方式,Flask中封装了一个flask_socketio库该库可以直接通过pip仓库安装,如下内容将重点简述SocketIO库在Flask框架中是如何被应用的,最…

网页终端直接操作linux系统【webssh】

1、安装pip linux系统默认都安装了python,但不一定安装了pip,所以先安装pip 我的系统中默认安装的是python2.7版本 curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py python get-pip.py 安装成功如图 2、安装webssh pip install w…

离线 安装webssh

1 安装包 和 webssh 代码准备 1 cmake 安装 安装参考文档: 文档地址 下载地址 $ tar xvfz cmake-3.24.2-linux-x86_64.tar.gz 配置环境全局变量 $ vim /etc/profile ​ # 添加 export PATH/root/webterminal/cmake-3.18.0-Linux-x86_64/bin:$PATH ​ $ source /etc/profil…

webshell是什么?

webshell是什么? 百度百科的定义:webshell就是以asp、php、jsp或者cgi等网页文件形式存在的一种代码执行环境,也可以将其称做为一种网页后门。黑客在入侵了一个网站后,通常会将asp或php后门文件与网站服务器WEB目录下正常的网页文…

Docker 容器内体验 WebSSH

Docker容器内体验 WebSSH 项目地址: https://pypi.org/project/webssh/ 容器创建 docker run -tid --name centos -p 8888:8888 -p 122:22 centos:7 /bin/bash # 启动容器写个比较呆的shell脚本&#xff0c;方便安装 cat <<EOF > wssh.sh yum -y install epel-re…

golang实现WebSSH的功能

在最近一次需求里&#xff0c;需要实现一个webSSH的功能&#xff0c;就是把terminal搬到web中来。要实现这个功能&#xff0c;可以采用websocketssh来说实现 1.第一步实现websocket websocket主要是ws或wss协议&#xff0c;其原理就是http协议升级成ws协议&#xff0c;即ws是…

纯Java实现一个网页版的Xshell

前言 最近由于项目需求&#xff0c;项目中需要实现一个WebSSH连接终端的功能&#xff0c;由于自己第一次做这类型功能&#xff0c;所以首先上了GitHub找了找有没有现成的轮子可以拿来直接用&#xff0c;当时看到了很多这方面的项目&#xff0c;例如&#xff1a;GateOne、webss…

webssh

vue djangolinux实现webssh 技术栈 xterm.js&#xff1a;做到vue的表现型 websocket&#xff1a; 做vue和django之间的通信 paramiko&#xff1a; 建立SSH连接通道 ssh&#xff1a; 与linux进行连接 threading&#xff1a;多条数据返回前端&#xff0c;io密集型&#xff0c;用…

webSSH如何安装?如何使用?解决Web端远程连接终端~~运维篇

Hi~由于博主公司业务有相当多的Linux终端设备&#xff0c;每次连上设备需要使用到外部工具&#xff0c;如&#xff1a;Xshell&#xff0c;每次都得去输入IP&#xff0c;端口&#xff0c;账号&#xff0c;密码相当的繁琐&#xff1b;偶尔看到阿里云远程连接终端功能挺有意思的&a…

超强功能WebSSH安装,解决Web远程SSH终端

项目地址&#xff1a;https://github.com/huashengdun/webssh 一个简单的 Web 应用程序&#xff0c;用作 ssh 客户端以连接到您的 ssh 服务器。它是用 Python 编写的&#xff0c;基于 tornado、paramiko 和 xterm.js。 特征&#xff1a; 支持SSH密码认证&#xff0c;包括空密…

webssh —— 浏览器上的终端

需求 近期接到一个需求&#xff0c;实现一个运行在浏览器上的终端&#xff0c;用于快速连接到公司设备。 Tip&#xff1a;只求实现的可直接跳到 「最终方案」 处 。 需求有以下几点 1、设备都不在公网状态下 2、webshell 需要免密登陆 3、动态连接的端口、账号、密码 4、可显…

webssh的安装与使用

最近研究了一下在web端实现一个远程连接终端操作的类似网页版xshell的实现。在网上搜索了一下发现已经有类似的操作在这里主要介绍以下两种。 https://github.com/huashengdun/websshhttps://github.com/billchurch/WebSSH2 我用的是虚拟机centos7系统&#xff0c;别的linux系…

简单分析实现运维利器---webssh终端

背景 现在几乎所有东西都向往着自动化,在运维界更是如此,运维人员都向往自动化代替人工操作、解决人工操作大量重复性工作的问题、故障主动恢复:及时发现;流程;解决。运维规范化:角色定义和责任划分、流程化等。但这些种种的目的,都离不开非常细小的技术支持,下面我们…

WebsocketWebSSH

什么是WebSSH? webssh 泛指一种技术可以在网页上实现一个 SSH 终端ssh终端&#xff1a;用来通过ssh协议&#xff0c;连接服务器进行管理运维开发方向&#xff1a;堡垒机登录、线上机器管理&#xff08;因为运维人员不可能24小时携带电脑&#xff09;在线编程&#xff1a;提供…

WebSSH神器sshwifty的安装与使用

本文章最初发表在XJHui’s Blog&#xff0c;未经允许&#xff0c;任何人禁止转载&#xff01; 为使您获得最好的阅读体验&#xff0c;强烈建议您点击 这里 前往 XJHui’s Blog 查看&#xff01; WebSSH工具 初衷 9.9买的一年服务器&#xff0c;不用实属可惜由于是计算机专业…

Sql Server查看表结构

1、表结构 2、通过 t abc 查询出的表结构 3、存储过程 t CREATE proc t TableName nvarchar(200) as SELECT (select top 1 isnull(value,) from sys.extended_properties ex_p where…

sql 查看表结构改动的记录

系统更新迭代比较大的情况&#xff0c;可能改动了比较多的数据库&#xff0c;留个笔记。。 select * from sys.objects order by modify_date desc 这句是查看数据库表的改动&#xff0c;希望对自己有帮助 -20180613

Access、SQLServer以及SQLite如何查询数据表结构

日期&#xff1a;2021年11月05日 作者&#xff1a;Commas 注释&#xff1a;整理了一下不同数据库如何获取数据表结构&#xff0c;比较有意思的玩法就是将不同数据库进行相互转换&#xff0c;由于篇幅问题&#xff0c;暂且仅讨论"数据表结构"的获取…… 目录 文章目录…

sqlServer 查看表结构(字段类型) (更新中)

对MySQL和Oracle熟悉的朋友知道用desc就可以查询一张表的结构&#xff0c;但是在SQL Server里执行desc命令会报错。 现提供两条命令查询表结构&#xff1a; 1.sp_help table_name; 2.sp_columns table_name; sp_help 直通车报表上周宝贝$; sp_columns 直通车报表…