webfactory / ssh-agent

GitHub Action to setup `ssh-agent` with a private key
MIT License
1.19k stars 246 forks source link

Can't get it to work – Permission denied #198

Open geoidesic opened 8 months ago

geoidesic commented 8 months ago

I had a go with this and it although I've put the private key into a secret and done:

name: Deploy to VPS

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - name: Set up SSH
      uses: webfactory/ssh-agent@v0.8.0
      with:
        ssh-private-key: ${{ secrets.VPS_SSH_PVT_KEY }}

    - name: Manually update known_hosts
      run: |
        mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts &&
        ssh-keyscan <ip_address> >> ~/.ssh/known_hosts

    - name: Deploy to VPS
      run: ssh -v cicd@<ip_address> "cd /var/www/html/edge-hello-world && git pull origin main"

It doesn't seem to find the key:

 debug1: Offering public key: --REDACTED-- agent
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: /home/runner/.ssh/id_rsa
debug1: Trying private key: /home/runner/.ssh/id_ecdsa
debug1: Trying private key: /home/runner/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/runner/.ssh/id_ed25519
debug1: Trying private key: /home/runner/.ssh/id_ed25519_sk
debug1: Trying private key: /home/runner/.ssh/id_xmss
debug1: Trying private key: /home/runner/.ssh/id_dsa
debug1: No more authentication methods to try.
cicd@<redacted-ip-address> Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
Error: Process completed with exit code 255.
OMKE commented 6 months ago

Did you manage to fix the issue, I have the same problem.