user3057416
user3057416

Reputation: 105

SSH auth fails with "Host key verification failed" despite providing valid keys

In Azure DevOps Pipelines I want to SSH to a private repo with dependencies. I am getting following error:

Host key verification failed. fatal: Could not read from remote repository.

Despite uploading private key to secure files and public key is set in project variables.

see below

steps:  
- task: InstallSSHKey@0
  inputs:
    hostName: $(hostname)
    sshPublicKey: $(testkey.pub)
    sshPassphrase: $(passphrase)
    sshKeySecureFile: testkey


- script: |
    git clone [email protected]:xxxx/xxxxx.git
  displayName: 'clone repo' 

Upvotes: 1

Views: 9565

Answers (3)

Big Bear Brian
Big Bear Brian

Reputation: 93

Can't comment on the previous post 'cause I've got less than 50 rep, but what anca was saying is paste from the following into the known_hosts file:

On Windows, this involves:

  1. Run Bash
  2. Copy the output starting "ssh.dev.azure.com ssh-rsa..."
  3. Paste into C:\Users<username>.ssh\known_hosts

Upvotes: 1

anca
anca

Reputation: 31

Maybe not the best solution:

  • bash: ssh-keyscan -t rsa < host_name > >> ~/.ssh/known_hosts

Upvotes: 3

Chris
Chris

Reputation: 137228

Host key verification failed

This doesn't refer to the SSH key you're trying to use to connect. It refers to the server's SSH public key fingerprint. This is the thing you see (and should check) when you first connect to a new machine.

Verifying the host key fingerprint protects against man-in-the-middle attacks, where a malicious third party could sit between you and your target server passing communication back and forth while observing or modifying said communication. The Azure documentation discusses this as well.

Manually SSH to the machine once, check that the fingerprint is what you expect it to be, and accept it. Subsequent connections should work unless the fingerprint changes.

Upvotes: 3

Related Questions