Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host key verification failed. #273

Open
debonx opened this issue Mar 16, 2024 · 1 comment
Open

Host key verification failed. #273

debonx opened this issue Mar 16, 2024 · 1 comment

Comments

@debonx
Copy link

debonx commented Mar 16, 2024

Hey all,

I have this problem as others.

Run if [ "refs/heads/4-implement-workflows" = "refs/heads/main" ]; then
  if [ "refs/heads/4-implement-workflows" = "refs/heads/main" ]; then
    rsync -avz dist/ ***@***:***
  else
    rsync -avz dist/ ***@***:***
  fi
  shell: /usr/bin/bash -e {0}
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(231) [sender=3.2.7]
Error: Process completed with exit code 255.

This is my workflow config

deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Install SSH Key
        uses: shimataro/ssh-key-action@v2
        with:
          name: github_rsa
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
          config: |
            Host ${{ secrets.SSH_HOST }}
              HostName ${{ secrets.SSH_HOST }}
              User ${{ secrets.SSH_USER }}
              IdentityFile ~/.ssh/github_rsa
              Port ${{ secrets.SSH_PORT }}
      - name: Deploy to VPS
        run: |
          if [ "${{ github.ref }}" = "refs/heads/main" ]; then
            rsync -avz dist/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_PRODUCTION_PATH }}
          else
            rsync -avz dist/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_STAGING_PATH }}
          fi

My secrets list in github

Screenshot 2024-03-16 at 11 39 09

Considerations:

  • I generated the SSH_KNOWN_HOSTS with the command ssh-keyscan -p PORT IP_ADDRESS against my remote host.
  • SSH_PRIVATE_KEY is obviously the private key installed on the remote host (IdentityFile in config).

Am I missing something?

@shimataro
Copy link
Owner

@debonx
Sorry for the late reply.

To isolate the problem, could you please remove name and config from with and tell me the result?
(If SSH_PORT is not 22, try rsync -e "ssh -p ${{ secrets.SSH_PORT }}")

Also, please check that your private key requires a passphrase.
(Private keys with passphrases cannot be used with this action at this time.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants