Dylan700 / sftp-upload-action

A GitHub Action for uploading files via SFTP
GNU General Public License v3.0
24 stars 12 forks source link

Error: connect: Cannot parse privateKey: Unsupported key format #28

Open shaneoreilly opened 5 months ago

shaneoreilly commented 5 months ago

Hi there,

I'm using this script as part of GitHub actions to deloy code to a server, but no matter what I change, I keep getting: Error: connect: Cannot parse privateKey: Unsupported key format

The SSH_KEY format is RSA, 2048-bit:

-----BEGIN OPENSSH PRIVATE KEY-----
123456
-----END OPENSSH PRIVATE KEY-----

I've also tried with RSA-4096 and it's the same error Here is the deploy.yml file:

name: Deploy to environment

# Trigger the workflow on push
on: push

# Authenticate to the the server via ssh
# and run our deployment script (sftp upload)
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: SFTP upload
        uses: Dylan700/sftp-upload-action@latest
        with:
          server: ${{ vars.SSH_HOST }}
          username: ${{ vars.SSH_USERNAME }}
          key: ${{ secrets.SSH_KEY }}
          port: 22
          uploads: |
            . => ${{ vars.SSH_FOLDER }}

Any ideas what could be causing this??

Dylan700 commented 5 months ago

Thanks for raising this and for using this action. Can you try running the action again with debug mode enabled? This should hopefully provide more information.

Otherwise, I would say you might have an error in the way you are providing the certificate. (I.e. newline characters or potential spaces at the start).

Also, have you used this action before, or is this your first time?