1

I'm trying to run a simple GitHub Action on my self-hosted runner (Windows 10), but I'm getting the error Host key verification failed. [error]fatal: Could not read from remote repository. Here's the code for the GitHub Action:

name: GitHub Actions Demo
on:
  push:
    branches: ["feature"]
jobs:
  build:
    runs-on: self-hosted
    steps:
      - name: Check out repository code
        uses: actions/checkout@v3

I've verified that the self-hosted runner is properly configured and connected to the repository, and I can manually clone and fetch the repository on the same machine without any issues. I've also tried running the ssh-keyscan command and adding the resulting host key to the known_hosts file, but that doesn't solve the problem.

ysief-001
  • 69
  • 12

1 Answers1

2

Instead of running directly the checkout action, try first running a

    steps:
      - name: Test SSH access
        run: ssh -Tv git@github.com

The is to see which key is communicated, and it the account used is the same as the one you are with, when you do your manual test (when the clone/fetch is working).

The OP ysief-001 then sees (in the comments)

After 1h30m I cancelled the workflow.
The last two lines are

Found key in C:\\Users\\ysief/.ssh/known_hosts:4 
read_passphrase: can't open /dev/tty: No such file or directory

That simply means a passphrase-protect (IE: encrypted) private key is not supported.
You need one without passphrase. (Or you can remove the passphrase from your existing key)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I did as suggested. After 1h30m I cancelled the workflow. The last two lines are ``Found key in C:\\Users\\ysief/.ssh/known_hosts:4`` and ``read_passphrase: can't open /dev/tty: No such file or directory``. Can you provide a guide to properly set up the ssh connection between Github Enterprise and the self-hosted runner? – ysief-001 Feb 16 '23 at 13:21
  • @ysief-001 Simply use a SSH key *without* passphrase, and it will work. – VonC Feb 16 '23 at 14:09
  • The reason for the issue was that the remote host's fingerprint was not included in the known_hosts file. After adding the fingerprint to the file, I am now receiving a different error message: ``You've successfully authenticated, but GitHub does not provide shell access. debug1: channel 0: free: client-session, nchannels 1 Transferred: sent 3420, received 2896 bytes, in 0.0 seconds Bytes per second: sent 162911.5, received 137950.8 debug1: Exit status 1 Error: Process completed with exit code 1.`` – ysief-001 Feb 16 '23 at 20:08
  • @ysief-001 That looks better! You can now resume with your initial checkout and see if this works. – VonC Feb 16 '23 at 20:12
  • No, I get the same error as before: ``Host key verification failed. [error]fatal: Could not read from remote repository.`` – ysief-001 Feb 16 '23 at 21:30
  • @ysief-001 When you got "You've successfully authenticated", did the account name mention in that message one that actually can clone/access the GitHub repository you want to check out? You do checkout a GitHub repository, right? – VonC Feb 16 '23 at 22:04
  • Yes, the account name is the same as the one that can access the repository and yes I do checkout a Github repository. – ysief-001 Feb 17 '23 at 10:31
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/251959/discussion-between-vonc-and-ysief-001). – VonC Feb 17 '23 at 11:43