actions / runner-images

GitHub Actions runner images
MIT License
10.19k stars 3.06k forks source link

Windoes ssh Host key verification failed. (With fix) #3684

Closed mgood7123 closed 3 years ago

mgood7123 commented 3 years ago

Description

on windows i get Host key verification failed. for testing ssh to github

debug1: read_passphrase: can't open /dev/tty: No such device or address
ls -l /dev/tty
crw-rw-rw- 1 runneradmin 197121 5, 0 Jul  2 13:46 /dev/tty

i am not sure why this is happening but it is preventing me from using my ssh key in windows

Virtual environments affected

Image version and build link

Environment: windows-2019 Version: 20210628.1

https://github.com/mgood7123/prebuilder/runs/2972861979

Is it regression?

No response

Expected behavior

Host key verification succeeds

Actual behavior

OpenSSH_8.5p1, OpenSSL 1.1.1k  25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [140.82.114.4] port 22.
debug1: Connection established.
debug1: identity file /c/Users/runneradmin/.ssh/id_rsa type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_dsa type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_xmss type -1
debug1: identity file /c/Users/runneradmin/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.5
debug1: Remote protocol version 2.0, remote software version babeld-4cec2db4
debug1: compat_banner: no match: babeld-4cec2db4
debug1: Authenticating to github.com:22 as 'git'
debug1: load_hostkeys: fopen /c/Users/runneradmin/.ssh/known_hosts: No such file or directory
debug1: load_hostkeys: fopen /c/Users/runneradmin/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: load_hostkeys: fopen /c/Users/runneradmin/.ssh/known_hosts: No such file or directory
debug1: load_hostkeys: fopen /c/Users/runneradmin/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: hostkeys_find_by_key_hostfile: hostkeys file /c/Users/runneradmin/.ssh/known_hosts does not exist
debug1: hostkeys_find_by_key_hostfile: hostkeys file /c/Users/runneradmin/.ssh/known_hosts2 does not exist
debug1: hostkeys_find_by_key_hostfile: hostkeys file /etc/ssh/ssh_known_hosts2 does not exist
debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.

Repro steps

    - name: System - EXTERNAL REPO - Verify SSH Key
      run: |
        eval $(ssh-agent -s)
        ssh-add YOUR_SSH_KEY <<< ${{env.YOUR_SSH_KEY_PASSPHRASE}}
        ls -l /dev/tty
        ssh -vT git@github.com || true
dibir-magomedsaygitov commented 3 years ago

Hello @mgood7123. Thank you for your report. We will take a look.

mgood7123 commented 3 years ago

this is fixed by doing

mkdir ~/.ssh || true
ssh-keyscan github.com 2>&1 >> ~/.ssh/known_hosts
dibir-magomedsaygitov commented 3 years ago

Hello @mgood7123. I'm going to close this issue since no action from image side is required. In case of any questions feel free to contact us.

mgood7123 commented 3 years ago

Hello @mgood7123. I'm going to close this issue since no action from image side is required. In case of any questions feel free to contact us.

Maybe you could add github to the list of allowed hosts in the images?