fscan/test/ssh-test-env/Dockerfile.ssh-server
ZacharyZcR de286026e8 refactor: 统一插件超时机制实现Context-First架构
- 重构SSH/MySQL/Redis插件超时控制,移除第三方库超时依赖
- 统一使用Go Context超时机制,提升超时控制可靠性和精确度
- 扩展MySQL/Redis/SSH插件默认端口支持,提升扫描覆盖率
- 修复插件系统中ConcurrentScanConfig超时配置缺失问题
- 优化插件检测逻辑,正确识别新架构插件并显示准确状态信息
- 解决插件在错误端口上长时间等待问题,显著提升扫描效率
2025-08-07 14:01:50 +08:00

63 lines
2.0 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 基于Ubuntu 20.04创建SSH测试服务器
FROM ubuntu:20.04
# 设置非交互式安装,避免安装过程中的提示
ENV DEBIAN_FRONTEND=noninteractive
# 更新包列表并安装必要的软件包
RUN apt-get update && \
apt-get install -y \
openssh-server \
sudo \
passwd \
netcat \
vim \
curl \
wget \
net-tools && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 创建SSH运行所需的目录
RUN mkdir /var/run/sshd
# 创建测试用户并设置密码 - 这些都是用于测试的弱密码账户
RUN useradd -m -s /bin/bash root2 && echo 'root2:password' | chpasswd
RUN useradd -m -s /bin/bash admin && echo 'admin:123456' | chpasswd
RUN useradd -m -s /bin/bash test && echo 'test:test123' | chpasswd
RUN useradd -m -s /bin/bash user && echo 'user:user' | chpasswd
RUN useradd -m -s /bin/bash guest && echo 'guest:guest' | chpasswd
RUN useradd -m -s /bin/bash oracle && echo 'oracle:oracle' | chpasswd
RUN useradd -m -s /bin/bash mysql && echo 'mysql:mysql' | chpasswd
RUN useradd -m -s /bin/bash ftp && echo 'ftp:ftp' | chpasswd
RUN useradd -m -s /bin/bash web && echo 'web:web123' | chpasswd
RUN useradd -m -s /bin/bash service && echo 'service:service123' | chpasswd
# 设置root用户密码通常用于测试
RUN echo 'root:password' | chpasswd
# 将admin和test用户添加到sudo组模拟管理员权限用户
RUN usermod -aG sudo admin
RUN usermod -aG sudo test
# 创建一些常见的系统用户,用于测试不同的访问场景
RUN useradd -m -s /bin/bash postgres && echo 'postgres:postgres' | chpasswd
RUN useradd -m -s /bin/bash redis && echo 'redis:redis123' | chpasswd
RUN useradd -m -s /bin/bash mongodb && echo 'mongodb:mongo123' | chpasswd
# 创建具有空密码的用户(极不安全,仅用于测试)
RUN useradd -m -s /bin/bash anonymous
RUN passwd -d anonymous
# 暴露SSH端口
EXPOSE 22
# 复制启动脚本
COPY scripts/start-ssh.sh /start-ssh.sh
RUN chmod +x /start-ssh.sh
# 设置工作目录
WORKDIR /root
# 启动SSH服务
CMD ["/start-ssh.sh"]