ssh-key-action icon indicating copy to clipboard operation
ssh-key-action copied to clipboard

Host key verification failed.

Open debonx opened this issue 5 months ago • 1 comments

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?

debonx avatar Mar 16 '24 10:03 debonx