How do cryptography in SSH(2) work (secure channel establishment, authentication)?
Does key authentication in SSH(2) protect from MitM by providing authentication and integrity and why?
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.
Sign up to join this communityHow do cryptography in SSH(2) work (secure channel establishment, authentication)?
Does key authentication in SSH(2) protect from MitM by providing authentication and integrity and why?
How do cryptography in SSH(2) work?
This is a very broad question. If you're interested in the details, then read the relevant RFCs that describe the SSH protocol. In particular:
Does key authentication in SSH(2) protect from MitM by providing authentication and integrity and why?
Assuming you're referring to Public Key Authentication (where a client authenticates by proving they hold the private key of a pre-shared public key), then not directly/entirely. Public key authentication is a feature of the SSH Authentication Protocol, which runs on top of the SSH Transport Protocol, and generally assumes that the transport protocol provides confidentiality and integrity.
The Public Key Authentication does provide some protection against mitm attacks (by associating the proof of the private key with the SSH session ID), which will prevent the mitm passing on the private key proof as an authentication credential, but won't prevent an attacker using other credentials to access the target system.
The primary mechanism for man-in-the-middle prevention in the SSH Transport Protocol is the verification of pre-shared (or otherwise verifiable via some trusted channel) host keys.
RFC 4251 - The Secure Shell (SSH) Protocol Architecture discusses potential Man-in-the-middle attacks on the SSH protocol and the approaches taken to prevent them.
I am sorry that I can not comment your post, and have to write this as answer...
But maybe you want to move this question to security.stackexchange.com.
And the security goal of key authentication is that both enities can be sure that the public key of the other person actually does belong to the other person. This should prevents a potential attacker from passing false keys to both parites in order to decipher their communication.
If by authentication and integrity you mean key authentication and key integrity, and by that you meant what i will just assume you meant, I would say yes, it protects from "this kind of" mitm attacks. But remember that there are still other methods to perform mitm attacks.