Skip to content

Instantly share code, notes, and snippets.

@kleo
Last active January 26, 2022 11:37
Show Gist options
  • Select an option

  • Save kleo/12a7d0f45406c1ea4e4e1d898fbfc16a to your computer and use it in GitHub Desktop.

Select an option

Save kleo/12a7d0f45406c1ea4e4e1d898fbfc16a to your computer and use it in GitHub Desktop.

generate keys for github actions rsync

on remote host

ssh-keygen -t rsa -b 4096 -N "" -f github-actions

cat github-actions.pub >> ~/.ssh/authorized_keys

on github repository

paste github-actions private key to github secrets to remote_key

 - name: transfer file rsync
        env:
          remote_port: 22
          remote_user: ${{ secrets.remote_user }}
          remote_host: ${{ secrets.remote_host }}
          remote_dir: ${{ secrets.remote_dir }}
          remote_key: ${{ secrets.remote_key }}
          local_dir: "./file"
        run: |
          mkdir ~/.ssh
          echo "$remote_key" > ~/.ssh/gh_actions_key
          chmod 600 ~/.ssh/gh_actions_key
          rsync -avzrh --progress --delete -e "ssh -p ${remote_port} -i ~/.ssh/gh_actions_key -o StrictHostKeyChecking=no -o LogLevel=ERROR" ${local_dir} ${remote_user}@${remote_host}:${remote_dir}
          
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment