Skip to content

Deploy to remote server using SSH fails on "Host key verification failed" #26564

Answered by felixmosh
felixmosh asked this question in Actions
Discussion options

You must be logged in to vote

I solved it!!!
Apparently keys were protected with passphrase 🤯.

Once I’ve generated a new ones without it, it worked.

So that is the whole process:

  1. Genereate new keys

    ssh-keygen -t rsa -b 4096 -C “user@host” -q -N “”

  2. Update your host’s authorized_keys

    ssh-copy-id -i ~/.ssh/id_rsa.pub user@host

  3. Enter the server & run 

    ssh-keyscan host

  4. Copy the output to github secret (let call it SSH_KNOWN_HOSTS)

  5. Copy the private key to a github secret (lets call it SSH_PRIVATE_KEY)

In your workflow.yml file

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Create SSH key
        run: |
          mkdir -p ~/.ssh/
          echo "$SSH_PRIVATE_KEY" > ../private.key
          sud…

Replies: 9 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ngohuytrieu
Comment options

@felixmosh
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants