Qual shell você está usando? Eu testei usando o zsh, mas o bash fará a mesma saída?
➜ ~ ssh localhost echo Hello world
Hello world
➜ ~ echo $?
0
➜ ~ ssh localhost error
bash: error: command not found
➜ ~ echo $?
127
➜ ~
➜ ~ ssh localhost fake
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:vYFp+5TGBtJd9XgvTJdKbK2pQSFwARcnOHtAYWyCfCE.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/user/.ssh/known_hosts:1
remove with:
ssh-keygen -f "/home/user/.ssh/known_hosts" -R localhost
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
bash: fake: command not found
➜ ~ echo $?
127