ssh-deploy: Permission denied (publickey).
I’m trying to use this action, but the job is completed and the files are not uploaded.
My steps.
I create a new EC2 instance, downloaded de PEM that I generated when created the instance.
I’ve alocated a Elastic IP to my instance, So i’m using it on REMOTE_HOST secret
Added the default ubuntu name on REMOTE_USER secret
Copied the content of my .pem key on SSH_PRIVATE_KEY secret
I dont created a REMOTE_TARGET.
After execute the job I’ve received the following warnings and the folder was not upload to my ec2 instance.

This is my workflow.yml
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- name: Deploy to Staging server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i"
SOURCE: "dist/"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
SCRIPT_BEFORE: |
whoami
ls -al
SCRIPT_AFTER: |
whoami
ls -al
echo $RSYNC_STDOUT
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 20 (4 by maintainers)
run this in your server:
cd ~/.ssh && cat id_rsa.pub >> authorized_keysThis is a frustrating issue, even if you are deploying locally, you still need to add the public key to authorized_keys, otherwise you won’t be able to login using your private key (and of course, you might need to configure some settings in sshd_config as well).
@LeonardoFurtado I had the same error, and it appears that this is the actual issue:
I would double check that your private key secret has a newline character at the end of the file, because for some reason libcrypto requires it to be a “valid format”
Added public key to authorized_keys and added a new line to private key. The issue still persists.
Don’t know why, but the private key secret requires a new line character at the end (Just hit the enter key). It solved my problem.
Hello guys i did follow the same steps but i still get this error on attachment