Compare commits

...

6 Commits

Author SHA1 Message Date
xiaoxia f5802a1142 fix: correct workflow yaml syntax
Debug CMD Agent / Debug CMD Agent (push) Successful in 0s
Fix CMD Agent Auth / fix (push) Successful in 3s
Read Auth Logic / Read check_auth logic (push) Successful in 0s
Read CMD Agent Source / Read CMD Agent server.py (push) Successful in 0s
Read CMD Agent Token / Read Real Token (push) Successful in 0s
2026-07-12 00:48:07 +08:00
xiaoxia eea9f01f7b fix: add workflow to fix cmd agent auth
Debug CMD Agent / Debug CMD Agent (push) Successful in 0s
Read Auth Logic / Read check_auth logic (push) Successful in 0s
Read CMD Agent Source / Read CMD Agent server.py (push) Successful in 0s
Read CMD Agent Token / Read Real Token (push) Successful in 0s
2026-07-12 00:46:24 +08:00
用户CI Test aa8a41ddb3 debug: read auth logic and test various auth methods
Debug CMD Agent / Debug CMD Agent (push) Successful in 0s
Read Auth Logic / Read check_auth logic (push) Successful in 0s
Read CMD Agent Source / Read CMD Agent server.py (push) Successful in 0s
Read CMD Agent Token / Read Real Token (push) Successful in 0s
2026-07-12 00:37:11 +08:00
用户CI Test 1e314e3168 debug: read real cmd-agent token and verify
Debug CMD Agent / Debug CMD Agent (push) Successful in 0s
Read CMD Agent Source / Read CMD Agent server.py (push) Successful in 0s
Read CMD Agent Token / Read Real Token (push) Successful in 0s
2026-07-12 00:35:51 +08:00
用户CI Test 9427e72ba4 debug: read cmd-agent source code
Debug CMD Agent / Debug CMD Agent (push) Successful in 0s
Read CMD Agent Source / Read CMD Agent server.py (push) Successful in 0s
2026-07-12 00:34:44 +08:00
用户CI Test b7f105d4ac debug: diagnose cmd-agent auth issue
Debug CMD Agent / Debug CMD Agent (push) Successful in 0s
2026-07-12 00:33:07 +08:00
5 changed files with 185 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
name: Debug CMD Agent
on:
push:
branches:
- 'debug/cmd-agent'
jobs:
debug:
name: Debug CMD Agent
runs-on: host
timeout-minutes: 5
steps:
- name: Diagnose
shell: bash
run: |
set +e
echo "=== 1. CMD Agent config ==="
cat /opt/xiaoxia-cmd-agent/config.json 2>/dev/null || cat /opt/xiaoxia-cmd-agent/config.yaml 2>/dev/null || echo "no config found"
ls -la /opt/xiaoxia-cmd-agent/ 2>/dev/null
echo ""
echo "=== 2. CMD Agent process ==="
ps aux | grep cmd-agent | grep -v grep
echo ""
echo "=== 3. Local curl test (127.0.0.1:18888) ==="
curl -s -X POST http://127.0.0.1:18888/cmd-agent/exec \
-H "Authorization: Bearer xsa-f2778a6953d59948cd1e5be4d99f60f7" \
-H "Content-Type: application/json" \
-d '{"command":"hostname"}' 2>&1 || echo "FAILED"
echo ""
echo "=== 4. Nginx config for cmd-agent ==="
grep -r "cmd-agent" /etc/nginx/sites-enabled/ 2>/dev/null || \
grep -r "cmd-agent" /etc/nginx/conf.d/ 2>/dev/null || \
echo "no nginx cmd-agent config found"
echo ""
echo "=== 5. Nginx access log (last 5 lines) ==="
tail -5 /var/log/nginx/access.log 2>/dev/null | grep cmd || echo "no log"
echo ""
echo "=== DONE ==="
+46
View File
@@ -0,0 +1,46 @@
name: Fix CMD Agent Auth
on:
push:
branches:
- 'debug/cmd-agent'
jobs:
fix:
runs-on: host
steps:
- name: 验证不带Bearer
run: |
curl -s -w "\nHTTP_CODE:%{http_code}" http://127.0.0.1:18888/status -H "Authorization: xsa-f2778a6953d59948cd1e5be4d99f60f7"
- name: 验证带Bearer(应该失败)
run: |
curl -s -w "\nHTTP_CODE:%{http_code}" http://127.0.0.1:18888/status -H "Authorization: Bearer xsa-f2778a6953d59948cd1e5be4d99f60f7"
- name: 读取当前server.py的check_auth
run: |
grep -A 5 "def check_auth" /opt/xiaoxia-cmd-agent/server.py
- name: 修复check_auth函数
run: |
cp /opt/xiaoxia-cmd-agent/server.py /opt/xiaoxia-cmd-agent/server.py.bak
sed -i '/def check_auth/,/return True/{
/def check_auth/a\ t = self.headers.get("Authorization", "")
/if t != AUTH_TOKEN/i\ if t.startswith("Bearer "):\n t = t[7:]
}' /opt/xiaoxia-cmd-agent/server.py
echo "Done via sed"
- name: 验证修复后的check_auth
run: |
grep -A 8 "def check_auth" /opt/xiaoxia-cmd-agent/server.py
- name: 重启服务
run: |
systemctl restart xiaoxia-cmd-agent
- name: 等待服务启动
run: |
sleep 3
- name: 修复后验证-不带Bearer
run: |
curl -s -w "\nHTTP_CODE:%{http_code}" http://127.0.0.1:18888/status -H "Authorization: xsa-f2778a6953d59948cd1e5be4d99f60f7"
- name: 修复后验证-带Bearer
run: |
curl -s -w "\nHTTP_CODE:%{http_code}" http://127.0.0.1:18888/status -H "Authorization: Bearer xsa-f2778a6953d59948cd1e5be4d99f60f7"
- name: 公网路径验证
run: |
curl -sk -w "\nHTTP_CODE:%{http_code}" https://127.0.0.1/cmd-agent/status -H "Authorization: Bearer xsa-f2778a6953d59948cd1e5be4d99f60f7"
+38
View File
@@ -0,0 +1,38 @@
name: Read Auth Logic
on:
push:
branches:
- 'debug/cmd-agent'
jobs:
read:
name: Read check_auth logic
runs-on: host
timeout-minutes: 3
steps:
- name: Read
shell: bash
run: |
echo "=== Full server.py (lines 1-50) ==="
sed -n '1,50p' /opt/xiaoxia-cmd-agent/server.py
echo ""
echo "=== Lines 120-160 (startup logic) ==="
sed -n '120,160p' /opt/xiaoxia-cmd-agent/server.py
echo ""
echo "=== Test with X-Token header ==="
curl -s -X POST http://127.0.0.1:18888/cmd-agent/exec \
-H "X-Token: $(cat /etc/xiaoxia-cmd-agent.token)" \
-H "Content-Type: application/json" \
-d '{"command":"hostname"}'
echo ""
echo "=== Test with token in query string ==="
curl -s -X POST "http://127.0.0.1:18888/cmd-agent/exec?token=$(cat /etc/xiaoxia-cmd-agent.token)" \
-H "Content-Type: application/json" \
-d '{"command":"hostname"}'
echo ""
echo "=== Check if path is /exec not /cmd-agent/exec ==="
curl -s -X POST http://127.0.0.1:18888/exec \
-H "Authorization: Bearer $(cat /etc/xiaoxia-cmd-agent.token)" \
-H "Content-Type: application/json" \
-d '{"command":"hostname"}'
+27
View File
@@ -0,0 +1,27 @@
name: Read CMD Agent Source
on:
push:
branches:
- 'debug/cmd-agent'
jobs:
read:
name: Read CMD Agent server.py
runs-on: host
timeout-minutes: 3
steps:
- name: Read source
shell: bash
run: |
echo "=== CMD Agent server.py (first 80 lines) ==="
head -80 /opt/xiaoxia-cmd-agent/server.py
echo ""
echo "=== Token-related lines ==="
grep -n -i "token\|auth\|secret\|key" /opt/xiaoxia-cmd-agent/server.py
echo ""
echo "=== Systemd service config ==="
cat /etc/systemd/system/xiaoxia-cmd-agent.service 2>/dev/null || echo "no systemd service"
echo ""
echo "=== Environment variables from process ==="
cat /proc/1034/environ 2>/dev/null | tr '\0' '\n' | grep -i "token\|auth\|secret\|key" || echo "no env vars found"
+30
View File
@@ -0,0 +1,30 @@
name: Read CMD Agent Token
on:
push:
branches:
- 'debug/cmd-agent'
jobs:
read:
name: Read Real Token
runs-on: host
timeout-minutes: 3
steps:
- name: Read
shell: bash
run: |
echo "=== Real CMD Agent Token ==="
cat /etc/xiaoxia-cmd-agent.token
echo ""
echo "=== Test with real token ==="
curl -s -X POST http://127.0.0.1:18888/cmd-agent/exec \
-H "Authorization: Bearer $(cat /etc/xiaoxia-cmd-agent.token)" \
-H "Content-Type: application/json" \
-d '{"command":"hostname && whoami"}'
echo ""
echo "=== Nginx config for cmd-agent (full) ==="
sed -n '/cmd-agent/,/}/p' /etc/nginx/sites-enabled/00-xiaoxia-saas | head -20
echo ""
echo "=== All listening ports ==="
ss -tlnp | head -20