pre1 1 2 ssh-keygen -t rsa ssh-copy-id -i xxx_rsa.pub root@x.x .x .x
pre2 1 github secrets add private -key example xxx_rsa
sample 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 name : Node.js CI on : push : branches : [ master ] pull_request : branches : [ master ] watch : types : [started] jobs : build : runs-on : ubuntu-latest strategy : matrix : node-version : [12.x] steps : - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses : actions/setup-node@v2 with : node-version : ${{ matrix.node-version }} - name: Install dependencies run : yarn --frozen-lockfile - run: yarn run build - run: tar -zcvf ./dist.tar.gz ./dist - name: deploy file uses : wlixcc/SFTP-Deploy-Action@v1.0 with : username : ${{ secrets.USERNAME }} server : ${{ secrets.HOST }} ssh_private_key : ${{ secrets.SSH_PRIVATE_KEY }} port : ${{ secrets.PORT }} local_path : './dist.tar.gz' remote_path : '/root/war' - name: executing remote ssh commands using ssh key uses : appleboy/ssh-action@master with : host : ${{ secrets.HOST }} username : ${{ secrets.USERNAME }} key : ${{ secrets.SSH_PRIVATE_KEY }} port : ${{ secrets.PORT }} script : /root/shell/default-jl.sh
GitHub Action SCP , another example Simple GitHub Action to copy a folder or single file to a remote server using SSH. This is working with the latest GitHub Actions .
✨ Example Usage Copy a folder recursively to a remote server
1 2 3 4 5 6 7 8 9 - name: Copy folder content recursively to remote uses: garygrossgarten/github-action-scp@release with: local: test remote: scp/directory host: ${{ secrets.HOST }} username: ${{ secrets.SSH_USER }} password: ${{ secrets.PASSWORD }}
Copy a single file to a remote server
1 2 3 4 5 6 7 8 9 - name: Copy single file to remote uses: garygrossgarten/github-action-scp@release with: local: test/oof.txt remote: scp/single/oof.txt host: ${{ secrets.HOST }} username: ${{ secrets.SSH_USER }} password: ${{ secrets.PASSWORD }}