问题
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 git@github.xxxxxx.com:xxxx/xxxxx.git
displayName: 'clone repo'
回答1:
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.
来源:https://stackoverflow.com/questions/55422479/ssh-auth-fails-with-host-key-verification-failed-despite-providing-valid-keys