一个计算机技术爱好者与学习者

0%

好好学Docker:使用Docker安装配置GateOne

1. GateOne简介

Gate One is a web-based Terminal Emulator and SSH client that brings the power of the command line to the web. It requires no browser plugins and is built on top of a powerful plugin system that allows every aspect of its appearance and functionality to be customized.

本文使用Docker安装配置GateOne,搭建一个Web Shell环境。
前置条件是安装配置好了docker环境,安装方法参考《Docker入门》。已知docker宿主机IP为192.168.56.130。

2. 安装GateOne

1、登录dockerhub查看需要的liftoff/gateone版本,实际上只有一个版本。

2、下载gateone镜像
docker pull liftoff/gateone

3、启动gateone服务

1
2
3
docker run --name=vk-gateone -d \
-p 8000:8000 \
liftoff/gateone gateone

以上命令:命名容器为vk-gateone,后台运行;映射宿主机8000端口到容器8000端口。

更多命令参考Using this Image

4、验证安装
docker ps
gateone启动正常的话就可以看到vk-gateone容器。
如果启动失败,可以使用docker logs vk-gateone查看失败原因并进行解决。

使用nc命令验证:

1
2
yum install nc
nc -v localhost 8000

浏览器访问: https://192.168.56.130:8000

5、使用
点击 Terminal:SSH ,输入主机IP、端口号、用户名和密码,即可登录主机。

如果想要添加鉴权验证,参考archlinux-GateoneAPI Authentication

3. 开放端口

如果浏览器无法访问8000端口,那么需要对防火墙进行设置。

1
2
3
4
firewall-cmd --add-port=8000/tcp --permanent
systemctl reload firewalld
# 或者
systemctl stop firewalld

4. 安装openssh-server

1、进入vk-gateone
docker exec -it vk-gateone /bin/bash

2、安装openssh-server

1
2
apt update
apt install openssh-server

3、vim /etc/ssh/sshd_config,如下修改:

1
PasswordAuthentication yes

4、重启ssh
service ssh restart

5、添加用户

1
2
3
4
5
6
useradd -m voidking -s /bin/bash
passwd voidking
adduser voidking sudo

# 安装sudo命令(该容器内没有sudo)
apt install sudo

6、登录vk-gateone容器
点击 Terminal:SSH ,主机名和端口使用默认,输入用户名voidking和密码,即可登录vk-gateone。

5. 小技巧

在gateone shell里,可以使用 ctrl+insert 进行复制,使用 shift+insert 进行粘贴。
如果在界面无法使用鼠标光标选中一些区域,那么可以在任意位置进行双击,即可激活光标选择。

  • 本文作者: 好好学习的郝
  • 原文链接: https://www.voidking.com/dev-docker-gateone/
  • 版权声明: 本文采用 BY-NC-SA 许可协议,转载请注明出处!源站会即时更新知识点并修正错误,欢迎访问~
  • 微信公众号同步更新,欢迎关注~