Search code examples
deploymentgithub-actionspleskssh-keys

I deploy 2 envs (test and prod), with 2 Github actions, same SECRETS, same user / ..ssh dir. I got unable to authenticate on prod only


I deploy my Symfony web app with Github Actions on a VPS under Plesk.
I have 2 environments, with the following dirs :

/~
  /httpdocs (production env)
  /test     (test env)
  /.ssh
    rw-r--r-- authorized_keys
    rw------- id_rsa
    rw-r--r-- id_rsa.pub
    rw-r--r-- known_hosts

all is under the same user:group.

I have the following Github Action SECRETS : HOST, PORT, USERNAME, PRIVATE_KEY, PASSPHRASE, REMOTE_DIR.

  • PRIVATE_KEY : id_rsa value in .ssh
  • PASSPHRASE : id_rsa password
  • REMOTE_DIR : absolute path to ~ (yes now it is useless, but it works)

authorized_keys : contains id_rsa.pub.
known_hosts : contains recent github hashes.

I have the following .yaml files :
For test : deploy-test.yaml :

name: Test deployment
on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  node_dependencies:
    name: deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: "Run deploy : ..."
        uses: appleboy/[email protected]
        with:
          host: ${{ secrets.HOST }}
          port: ${{ secrets.PORT }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.PRIVATE_KEY }}
          passphrase: ${{ secrets.PASSPHRASE }}
          script: cd ${{ secrets.REMOTE_DIR }}/test && ./deploy.test.sh

For production : deploy-prod.yaml :

name: Production deployment
on:
  push:
    branches:
      - production
  workflow_dispatch:

jobs:
  node_dependencies:
    name: deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: "Run deploy : ..."
        uses: appleboy/[email protected]
        with:
          host: ${{ secrets.HOST }}
          port: ${{ secrets.PORT }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.PRIVATE_KEY }}
          passphrase: ${{ secrets.PASSPHRASE }}
          script: cd ${{ secrets.REMOTE_DIR }}/httpdocs && ./deploy.sh

The test action works very well, but the production action give me :

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

My .sh files have the -x right.

The SECRETS, so the user and the .ssh dir are the same for both actions.

How is it possible ?!


Solution

  • Upgrade appleboy/ssh-action solved the problem. So, if you fall here, pay attention to your appleboy/ssh-action version, particularly if you are < 0.1.5.