Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rsync fails Permission denied (publickey) #233

Open
shubhank008 opened this issue Jan 25, 2023 · 2 comments
Open

Rsync fails Permission denied (publickey) #233

shubhank008 opened this issue Jan 25, 2023 · 2 comments

Comments

@shubhank008
Copy link

Install SSH Key working

Run shimataro/ssh-key-action@v[2](https://github.com/gamerplex/kinland2/actions/runs/4005511431/jobs/6876611514#step:3:2)
  with:
    key: ***
  
    name: id_rsa
    known_hosts: just-a-placeholder-so-we-dont-get-errors
    if_key_exists: replace
SSH key has been stored to /home/runner/.ssh successfully.

But when running rsync command, it fails

Run rsync -avzr ./build/WebGL/* root@***:/home/steve777/apps/***-Web/                 
  rsync -avzr ./build/WebGL/* root@***:/home/steve777/apps/***-Web/                 
  shell: /usr/bin/bash -e {0}
root@***: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code [2]
Error: Process completed with exit code 2[5]

I am also using appleboy/ssh-action with same host and private_key but that works fine.

Run appleboy/ssh-action@v0.1.6
  with:
    host: ***
    username: root
    key: ***
    port: 22
    script: cd /home/steve777/apps/***-Web
  rm -rf *
  
    sync: false
    use_insecure_cipher: false
    timeout: 0s
    command_timeout: 10m
    proxy_port: 22
    proxy_timeout: 30s
    proxy_use_insecure_cipher: false
    script_stop: false
    debug: false

======CMD======
cd /home/steve[7](https://github.com/gamerplex/kinland2/actions/runs/4005511431/jobs/6876611514#step:7:7)77/apps/Kinland-Web
rm -rf *

======END======
==============================================
✅ Successfully executed commands to all host.
==============================================

Workflow

deployToWebServer:
    needs: [BuildWebGL]
    #runs-on: self-hosted
    runs-on: ubuntu-latest
    steps:
      - name: Install SSH Key
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_PRIVATE_KEY }} 
          name: id_rsa
          known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
          if_key_exists: replace
          
      - name: Adding Known Hosts
        run: ssh-keyscan -H ${{ secrets.SSH_HOST_WEBGL }} >> ~/.ssh/known_hosts
      
  
        #Checkout
      - uses: actions/checkout@v3
        with:
            #fetch-depth: 0
            #Branch
            ref: main
            fetch-depth: 1
            submodules: recursive
            #token:  ${{ secrets.MY_PAT }}
 
        #Repeat for all builds, copy paste this step
      - name: Download WebGL Artifact
        uses: actions/download-artifact@v2
        with:
          name: Build-WebGL
          path: build/WebGL
      
      - name: Cleanup Remote Old Files
        uses: appleboy/ssh-action@v0.1.6
        with:
            host: ${{ secrets.SSH_HOST_WEBGL }}
            username: root
            key: ${{ secrets.SSH_PRIVATE_KEY_WEBGL }} 
            port: 22
            script: |
              cd /home/steve777/apps/***-Web
              rm -rf *
      
      - name: Deploy with rsync
        run: |
            rsync -avzr ./build/WebGL/* root@${{ secrets.SSH_HOST_WEBGL }}:/home/steve777/apps/***-Web/    
@splitbrain
Copy link

I had the same problem. Adding the user's public key to the authorized_keys file fixed the issue for me.

@RevealedFrom
Copy link

I had the same problem. Adding the user's public key to the authorized_keys file fixed the issue for me.

I am getting a similar Permission denied issue. Which "user" are you referring to, and the authorized_keys file on where?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants