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

git pull returns Permission denied (publickey) #232

Closed
bitrixdevelop opened this issue Mar 14, 2023 · 11 comments
Closed

git pull returns Permission denied (publickey) #232

bitrixdevelop opened this issue Mar 14, 2023 · 11 comments

Comments

@bitrixdevelop
Copy link

bitrixdevelop commented Mar 14, 2023

Hello!
I wanted to automatically pulling changes on the dev server after the push.

My action:

name: Remote SSH
on:

  • push
    jobs:
    build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    • name: executing remote ssh commands using password
      uses: appleboy/ssh-action@master
      with:
      host: ${{ secrets.IP }}
      username: ${{ secrets.USER }}
      password: ${{ secrets.PRIVATE_KEY }}
      port: ${{ secrets.PORT }}
      script: |
      ${{ secrets.SCRIPT }}

The SCRIPT contains the following commands:

cd /home/project
git pull origin master

When I run the action, I get the following message:

======END======
err: git@github.com: Permission denied (publickey).
err: fatal: Could not read from remote repository.
err: Please make sure you have the correct access rights
err: and the repository exists.
2023/03/14 15:17:10 Process exited with status 1

The action connects under root. If I run the same commands manually under it, then there is no error, the pool is successful. Help me please!

@BlackRandomCraft
Copy link

maybe u change steps.password to steps.key?

@bitrixdevelop
Copy link
Author

I tried, but nothing happened

@AntonioKichaev
Copy link

if u use git like ssh, i recommend u remove passphrase

ssh-keygen -p -f ~/.ssh/id_rsa

and leave field passphrame empty
this worked for me, try to do this

@appleboy
Copy link
Owner

Please add your private key to deploy keys page as below

image

    - name: pull private repository
      uses: appleboy/ssh-action@v0.1.10
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.DEPLOY_SSH_KEY }}
        port: ${{ secrets.PORT }}
        script_stop: true
        script: |
          git clone git@github.com:go-training/self-runner.git test_repository2
          cd test_repository2 && git pull
          rm -rf test_repository2

It is working for me. See the output log

image

@aktienautobahn
Copy link

aktienautobahn commented Jun 29, 2023

It is not allowed to add private key to the deploy key page, as you wrote, because : "Key is invalid. You must supply a key in OpenSSH public key format".

I can pull manually without password: my SSH-authentification works.

But with this github actions does not:

I can perform ssh commands but not authenticate with github:

err: Cloning into 'personal-site'...
err: git@github.com: Permission denied (publickey).
err: fatal: Could not read from remote repository.
err: Please make sure you have the correct access rights
err: and the repository exists.

My shortened config file:
Screenshot 2023-06-29 at 1 28 22 AM

if I change the key to
key: ${{ secrets.DEPLOY_SSH_KEY }}
I can not authenticate with VPS server at all, cause I need a key to perform commands inside the VPS bash.

@webbyus
Copy link

webbyus commented Sep 25, 2023

Please add your private key to deploy keys page as below

image

    - name: pull private repository
      uses: appleboy/ssh-action@v0.1.10
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.DEPLOY_SSH_KEY }}
        port: ${{ secrets.PORT }}
        script_stop: true
        script: |
          git clone git@github.com:go-training/self-runner.git test_repository2
          cd test_repository2 && git pull
          rm -rf test_repository2

It is working for me. See the output log

image

If its success , why it shows "err Cloning into ...."

@lkp-k
Copy link

lkp-k commented Sep 29, 2023

same, why does it show err?

So confusing

@appleboy

@alejandroaquintero
Copy link

Please add your private key to deploy keys page as below

image

    - name: pull private repository
      uses: appleboy/ssh-action@v0.1.10
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.DEPLOY_SSH_KEY }}
        port: ${{ secrets.PORT }}
        script_stop: true
        script: |
          git clone git@github.com:go-training/self-runner.git test_repository2
          cd test_repository2 && git pull
          rm -rf test_repository2

It is working for me. See the output log

image

Can not add a private key as a deploy key

image

@JosefSaltz
Copy link

Also running into this issue, not sure if there's been a revision to how GH handles Deploy Keys specifically. I guess work around is to use regular repo secrets?

@viniciusaugutisps
Copy link

viniciusaugutisps commented Nov 3, 2023

Same problem here. Did anyone manage to solve this problem?

@blekmus
Copy link

blekmus commented Dec 11, 2023

I had the same problem. Only solution was to start the ssh-agent and add the private key.

name: Deploy App
on: [push]
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: remote execution
      uses: appleboy/ssh-action@v1.0.0
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        port: ${{ secrets.PORT }}
        key: ${{ secrets.KEY }}
        script: |
          eval `ssh-agent -s`
          ssh-add ~/.ssh/git_id_rsa
          cd ${{ secrets.PATH}} 
          git pull

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