Github action to connect via SSH
I try to use github actions (appleboy/ssh-action) to connect via SSH to a Linode of mine.
This is how the workflow file looks like.
name: Connect to Linode
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: ls of linode container
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.LINODE_HOST }}
username: ${{ secrets.LINODE_USERNAME }}
key: ${{ secrets.LINODE_SSHKEY }}
port: ${{ secrets.LINODE_PORT }}
script: |
ls -l
The key
contains the private key of the key-pair I'm using to connect manually via command line.
As port
I use 22, hope this is correct.
It does not work. I'm getting the following error.
ssh: handshake failed: ssh: unable to authenticate
What am I doing wrong?
Is there a better github action to use?
Thanks already!
2 Replies
Did you give GitHub the public key?
See here:
https://virtualzero.net/blog/how-to-add-an-ssh-public-key-to-github-from-Ubuntu-18.04-lts
You can skip down to step 7.
-- sw
Hi @tobirie
I had the same problem.
Solved for me giving the allowed permissions for the keys in the remote server.
Change the permissions of .ssh
to 700
Change the permissions of .ssh/authorized_keys
to 640
here is my .yml
name: re-deploy application
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER_NAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
./re-deploy.sh