GitHub Action "Host key verification failed"

199 views Asked by At

Hope you are doing well .. I am new to CI/CD and implementing via GitHub Actions. I followed steps and having an issue on deployment. I am getting this error

Run ssh -p 2200 ***@*** "cd *** && git checkout *** && git pull && exit"
Host key verification failed.
Error: Process completed with exit code 255.

and my ymal file is

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  run_pull:
    name: run pull
    runs-on: ubuntu-latest

    steps:
    - name: connect and pull
      run: ssh -p 2200 ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ secrets.MAIN_BRANCH }} && git pull && exit"

I generated the SSH key and added into authorized_keys, i get GitHub Fingureprints from https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints and add them to known_host. but still getting this error.

Any clue, am i doing something wrong or missing something ? thanks in advance.

PS: I want to deploy a PHP script to Server via SSH

1

There are 1 answers

0
Ryabchenko Alexander On

I have similar problem.

One of root causes was missed rec in ~/.ssh/authorized_keys

After fix, all works for me with next config

name: Deploy lending to Server

on:
  push:
    branches:
      - main  # Adjust this if you're using a different branch

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Set up SSH key
      uses: webfactory/[email protected]
      with:
        ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

    - name: Deploy via SSH
      run: |
        ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "mkdir -p /var/www/kokyangwuti/landing"