Strovent SystemsSign in
Reference

Host key verification failed through a jump host (ProxyJump)

With ProxyJump, your own computer checks the host keys of both the jump host and the target, in your known_hosts. Find which host failed, then fix that entry.

Host key verification failed. through a jump host means one of the two host-key checks failed. With ssh -J or ProxyJump, your own computer checks both: the jump host's key and the target's key, each against your local known_hosts. The jump host's own known_hosts file is not involved.

How the connection is built

OpenSSH turns -J jump.example.com into a second ssh process on your computer, run as ssh -W '[target]:port' jump.example.com. That process logs in to the jump host and asks it to open a TCP connection to the target. Your main ssh then talks to the target through that tunnel, end to end. So:

  • Two host keys are checked, both on your computer, both in your files.
  • Both processes read your ~/.ssh/config.
  • Options you put on the command line, such as -o StrictHostKeyChecking=ask, apply to the target only, not to the jump host. Put jump-host settings in a Host block in ~/.ssh/config.

Find which host failed

Read the line just above Host key verification failed. It names the host:

  • No ED25519 host key is known for 10.0.0.5 and you have requested strict checking. The host is new to you, and StrictHostKeyChecking yes is set for it, so ssh will not ask. Get the key fingerprint from the host's admin, and connect once with StrictHostKeyChecking ask (the default) to check and save it.
  • WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! The saved key for that host does not match. Read the Offending key in ... :line line to see which entry. See Read the SSH warning "REMOTE HOST IDENTIFICATION HAS CHANGED".
  • No message, just the failure. The prompt could not be shown. BatchMode yes turns off host-key prompts, so a first connection fails instead of asking.

When the target is reached through a proxy, the first-connect prompt (The authenticity of host '10.0.0.5 (...)' can't be established.) shows the words no hostip for proxy command, in angle brackets, where the IP address would be. That is normal. Your computer never connects to the target's address itself, so it cannot show or check it.

The old pattern: ssh inside ProxyCommand

Some older configs reach the target with a second ssh that runs on the jump host:

ProxyCommand ssh jump.example.com ssh target.example.com

Here the inner ssh checks the target's key against the jump host's known_hosts, and it has no terminal to prompt on. For a target it has never seen, it fails with Host key verification failed. even though your own known_hosts is fine. Replace it with ProxyJump jump.example.com, or ProxyCommand ssh -W %h:%p jump.example.com.

Same private address behind two jump hosts

known_hosts stores keys under the name you connect to. If two networks both have a 10.0.0.5, reached through different jump hosts, the second one looks like a changed key. Give each one its own name with HostKeyAlias:

Host app-east
    HostName 10.0.0.5
    ProxyJump jump-east.example.com
    HostKeyAlias app-east

Host app-west
    HostName 10.0.0.5
    ProxyJump jump-west.example.com
    HostKeyAlias app-west

A target on a port other than 22 is saved as [10.0.0.5]:2222, so remove or check it under that name, for example ssh-keygen -R '[10.0.0.5]:2222'.

Do not fix this by setting StrictHostKeyChecking no or UserKnownHostsFile /dev/null. That removes the check that tells you which machine you reached.

Sources

  • ssh(1) (-J, command-line options apply to the destination, VERIFYING HOST KEYS)
  • ssh_config(5) (ProxyJump, ProxyCommand, HostKeyAlias, StrictHostKeyChecking, BatchMode)
  • sshd(8) (known_hosts format, [host]:port)
  • OpenSSH ssh.c (ProxyJump becomes ssh -W)
  • OpenSSH sshconnect.c (message texts, no hostip for proxy command)

Spotted a mistake? Email [email protected].