name: Deploy to Server
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Sync files to server
run: |
rsync -avz --delete-after
-e "ssh -i ${{ secrets.SSH_PRIVATE_KEY }} -p 222 -o StrictHostKeyChecking=no"
./ [email protected]:/var/www/crm
When pushing the code to master branch the action getting started but failed on this error
Run rsync -avz --delete-after
rsync -avz --delete-after
-e "ssh -o StrictHostKeyChecking=no -p 222"
./ [email protected]:/var/www/crm
shell: /usr/bin/bash -e {0}
Warning: Permanently added '[192.168.1.1]:222' (ED25519) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
[email protected]: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7]
Error: Process completed with exit code 12.
I added public key on Github with name SSH_PRIVATE_KEY and I have id_rsa, id_rsa.pub and authorised_keys file
on this location ~/.ssh/ on the server.
I dont know what I am doing wrong, I have the SSH key passwordless.
I believe there is a typo and I corrected it here:
ssh -i ~/.ssh/id_rsa -p 222 ….
I also suspect a typo here
I added public key on Github with name SSH_PRIVATE_KEY
Did you mean to say “private key”?
Also did you place the public key into
/root/.ssh/authorised_keys
on the target server 192.168.1.1?
Is this IP address correct? It looks surprising, considering that you are running on a GitHub hosted runner.