TNT/test_anonymous_access.sh
m1ngsama 5f8b8fd843 feat: enhance anonymous access and long-term stability
Improvements for low-barrier anonymous access:
- Enhanced welcome message to clarify anonymous access
- Added EASY_SETUP.md guide in Chinese and English
- Updated README with anonymous access notes

Long-term stability enhancements:
- Improved systemd service with auto-restart and resource limits
- Added log rotation script (scripts/logrotate.sh)
- Added health check script (scripts/healthcheck.sh)
- Added cron setup script for automated maintenance
- Added anonymous access test suite

Testing:
- All security features verified (10/10 passed)
- Anonymous access tests passed (2/2)
- Health check verified

This ensures:
- Zero-barrier SSH access (any username, any password)
- Stable long-term operation with auto-restart
- Automated log management
- Continuous health monitoring
2026-01-22 15:06:54 +08:00

62 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# Test anonymous SSH access
echo "Testing anonymous SSH access to TNT server..."
echo ""
# Test 1: Connection with any username and password
echo "Test 1: Connection with any username (should succeed)"
timeout 5 expect -c '
spawn ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2223 testuser@localhost
expect {
"password:" {
send "anypassword\r"
expect {
"请输入用户名:" {
send "TestUser\r"
send "\003"
exit 0
}
timeout { exit 1 }
}
}
timeout { exit 1 }
}
' 2>&1 | grep -q "请输入用户名"
if [ $? -eq 0 ]; then
echo "✓ Test 1 PASSED: Can connect with any password"
else
echo "✗ Test 1 FAILED: Cannot connect with any password"
fi
echo ""
# Test 2: Connection should work without special SSH options
echo "Test 2: Simple connection (standard SSH command)"
timeout 5 expect -c '
spawn ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2223 anonymous@localhost
expect {
"password:" {
send "\r"
expect {
"请输入用户名:" {
send "\r"
send "\003"
exit 0
}
timeout { exit 1 }
}
}
timeout { exit 1 }
}
' 2>&1 | grep -q "请输入用户名"
if [ $? -eq 0 ]; then
echo "✓ Test 2 PASSED: Can connect with empty password"
else
echo "✗ Test 2 FAILED: Cannot connect with empty password"
fi
echo ""
echo "Anonymous access test completed."