T09 · Insecure Skill Coding Practices
- Location
scripts/ssh-key-setup.sh:52- Finding
SSH Destination Option Injection Through Unvalidated User and Host Arguments
- Content
View full analysis
[user]" return 1 fi if [ ! -f "$SSH_DIR/$DEFAULT_KEY" ]; then echo "❌ 私钥不存在,请先运行 gen" return 1 fi if ! command -v sshpass &>/dev/null; then echo "正在安装 sshpass..." if command -v apt-get &>/dev/null; then DEBIAN_FRONTEND=noninteractive apt-get install -y -qq sshpass 2>&1 elif command -v yum &>/dev/null; then yum install -y -q sshpass 2>&1 fi fi echo "📤 部署公钥到 ${user}@${host} ..." sshpass -p "$SSHPASS" ssh-copy-id -o StrictHostKeyChecking=no "${user}@${host}" 2>&1 echo "✅ 公钥已部署" } cmd_test() { local host="$1" local user="${2:-root}" if [ -z "$host" ]; then echo "❌ 用法: test [user]" return 1 fi echo "🔗 测试免密登录 ${user}@${host} ..." if ssh -o ConnectTimeout=5 -o BatchMode=yes "${user}@${host}" "echo '✅ 免密登录成功' && hostname" 2>&1; then echo "✅ 连接正常" else echo "❌ 免密登录失败,请检查公钥是否已部署" return 1 fi } cmd_info() { local host="$1" local user="${2:-root}" if [ -z "$host" ]; then echo "❌ 用法: info [user]" return 1 fi echo "📊 远程主机信息: ${user}@${host}" ssh -o ConnectTimeout=5 "${user}@${host}" bash -c ' echo " 主机名: $(hostname)" echo " 系统: $(cat /etc/os-release 2>/dev/null | grep PRETTY_NAME | cut -d= -f2 | tr -d \"\")" echo " 内核: $(uname -r)" echo " 架构: $(uname -m)" echo " 内存: $(free -h | awk "/^Mem:/{print \$2\" total, \"\$7\" available\"}")" echo " 磁盘: $(df -h / | awk "NR==2{print \$2\" total ...[truncated 1904 chars]- Remediation
View remediation
