i have an issue with my github action and i can’t connect with ssh i did this :
-
Create an ssh key with user adam
-
Copy the public key into /root/.ssh/authorized_keys
-
Create a secret in github with the public key
-
Create a script.sh into /home/adam/
-
chmod 600 .ssh directory
But i got this error :
Run ssh -o StrictHostKeyChecking=no
Warning: Identity file /home/adam/.ssh/id_rsa not accessible: No such file or directory.
Warning: Permanently added ‘my Ip’ (ED25519) to the list of known hosts.
adam@my Ip: Permission denied (publickey,password,keyboard-interactive).
Error: Process completed with exit code 255.
This is my code :
name: Run script on VPS
on:
push:
branches: [master]
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run script
env:
SSH_PRIVATE_KEY: ${{ secrets.VPS_SSH_PUBLIC_KEY }}
run: |
ssh -o StrictHostKeyChecking=no
-o PasswordAuthentication=no
-i /home/adam/.ssh/id_rsa
adam@myip
"bash /home/adam/script.sh"
Can someone help me fix this ?
- tried to verify if the path to the id_rsa and id_rsa.pub is correct
- saw both files were there and with the good key inside
- tried reacreate ssh key multiples time
- tried different way to access ssh
- verify conf open ssh accept rsa and add this line
CASignatureAlgorithms +ssh-rsa
- restart service ssh
2
Answers
thank you for your answers I don't know exactly what was the issue but i think it was related with the ssh key
I fixed my code by using password that is store in secret of github instead of ssh key
That is on the remote target server you want to SSH to.
And it means you want to SSH to as root:
root@remoteServer:...
.Not as
adam@...
Instead of relying on local path which does not exist on GitHub runner (unless maybe self-hosted), you might want to use the GitHub Action "
appleboy/ssh-action
"Remove the
passphrase: ${{ secrets.PASSPHRASE }}
line if your SSH private key is not passphrase protected.That way, you do not need to create
.ssh/
folder with the right permission. That action takes care of all that for you.