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

80 lines
2.0 KiB
Bash
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.

#!/bin/bash
# SSH测试服务器启动脚本
set -e
echo "=== SSH Test Server Starting ==="
# 生成SSH主机密钥如果不存在
echo "Generating SSH host keys..."
ssh-keygen -A
# 创建必要的目录
mkdir -p /var/run/sshd
mkdir -p /var/log
# 设置正确的权限
chmod 700 /var/run/sshd
# 创建测试用户的SSH目录并设置权限
for user in root root2 admin test user guest oracle mysql ftp web service postgres redis mongodb; do
if id "$user" &>/dev/null; then
user_home=$(eval echo "~$user")
mkdir -p "$user_home/.ssh"
chown "$user:$user" "$user_home/.ssh"
chmod 700 "$user_home/.ssh"
# 为一些用户创建authorized_keys文件用于公钥认证测试
if [ "$user" = "admin" ] || [ "$user" = "test" ]; then
touch "$user_home/.ssh/authorized_keys"
chown "$user:$user" "$user_home/.ssh/authorized_keys"
chmod 600 "$user_home/.ssh/authorized_keys"
fi
fi
done
# 显示所有测试用户账户信息
echo "=== Test Users Created ==="
echo "Root accounts:"
echo " root:password"
echo " root2:password"
echo ""
echo "Admin accounts:"
echo " admin:123456 (sudo access)"
echo " test:test123 (sudo access)"
echo ""
echo "Regular users:"
echo " user:user"
echo " guest:guest (chroot enabled)"
echo " web:web123"
echo " service:service123"
echo ""
echo "Database users:"
echo " oracle:oracle"
echo " mysql:mysql"
echo " postgres:postgres"
echo " redis:redis123"
echo " mongodb:mongo123"
echo ""
echo "System users:"
echo " ftp:ftp"
echo " anonymous:<no password>"
echo ""
echo "=== SSH Server Configuration ==="
echo "Port: 22"
echo "Password Authentication: Enabled"
echo "Root Login: Enabled"
echo "Empty Passwords: Enabled (for anonymous user)"
echo "Max Auth Tries: 6"
echo ""
# 显示网络信息
echo "=== Network Information ==="
echo "Container IP: $(hostname -I)"
echo "Mapped port: Check docker-compose.yml for port mapping"
echo ""
# 启动SSH服务
echo "Starting SSH daemon..."
exec /usr/sbin/sshd -D -e