Execute SSH Commands #245
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Execute SSH Commands | |
on: | |
workflow_dispatch: # 手动触发工作流 | |
schedule: | |
- cron: "30 1,13 * * *" # 每天早晚9点运行一次 | |
jobs: | |
execute-commands: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up SSHPass | |
run: sudo apt-get update && sudo apt-get install -y sshpass | |
- name: Get ACCOUNTS_JSON | |
id: get-accounts | |
run: | | |
echo "$ACCOUNTS_JSON" > accounts.json | |
env: | |
ACCOUNTS_JSON: ${{ secrets.ACCOUNTS_JSON }} | |
# 从 GitHub Secrets 获取 ACCOUNTS_JSON 变量,并保存到文件 accounts.json | |
- name: Generate SSH Commands | |
id: generate-ssh-commands | |
run: | | |
echo "#!/bin/bash" > sshpass.sh | |
while IFS= read -r account; do | |
username=$(echo "$account" | jq -r '.username') | |
password=$(echo "$account" | jq -r '.password') | |
ssh=$(echo "$account" | jq -r '.ssh') | |
echo "echo \"Executing for $username@$ssh\"" >> sshpass.sh | |
echo "sshpass -p '$password' ssh -o StrictHostKeyChecking=no '$username@$ssh' 'bash <(curl -s https://raw.githubusercontent.com/gshtwy/socks5-hysteria2-for-serv00/main/crtest.sh)'" >> sshpass.sh | |
done < <(jq -c '.[]' accounts.json) | |
chmod +x sshpass.sh | |
- name: Execute SSH Commands | |
run: ./sshpass.sh |