2025-04-05 13:40:38 +08:00

28 lines
651 B
YAML
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.

name: SSH 连接测试
on:
workflow_dispatch: # 手动触发
push:
branches:
- main # 仅main分支触发
jobs:
ssh-test:
runs-on: ubuntu-latest
steps:
- name: 检查SSH密钥
run: |
if [ -z "${{ secrets.KEY }}" ]; then
echo "SSH私钥未配置"
exit 1
fi
echo "SSH私钥已配置"
- name: 测试SSH连接
run: |
echo "${{ secrets.KEY }}" > ssh_key
chmod 600 ssh_key
ssh -o StrictHostKeyChecking=no \
-i ssh_key \
${{ secrets.USER }}@${{ secrets.HOST }} "echo 'SSH连接成功'"