07/05/2025, 21:46 Feed | LinkedIn
How Does SSH Work?
What actually happens when you type ssh user@host?
SSH (Secure Shell) is a network protocol used to securely connect to remote machines over an unsecured network.
It ensures confidentiality, integrity, and authentication for remote access, file transfers, and command execution,
protecting data from eavesdropping and tampering.
The visual below lays out the sequential steps that occur between the SSH client and the SSH server.
Here’s a breakdown of the main events that occur during an SSH connection:
𝟭) 𝗞𝗲𝘆 𝗲𝘅𝗰𝗵𝗮𝗻𝗴𝗲
SSH begins with a key exchange process, typically using the Diffie-Hellman algorithm. The client and server
exchange public components to derive a shared secret, creating a secure session key for encrypted communication
without transmitting sensitive private keys.
𝟮) 𝗦𝗲𝗿𝘃𝗲𝗿 𝘃𝗲𝗿𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻
The client validates the server’s identity by checking its public key against a locally stored known_hosts file. This
prevents man-in-the-middle (MITM) attacks, ensuring the connection is established only with a trusted server.
𝟯) 𝗦𝗲𝘀𝘀𝗶𝗼𝗻 𝗸𝗲𝘆 & 𝗲𝗻𝗰𝗿𝘆𝗽𝘁𝗶𝗼𝗻 𝘀𝗲𝘁𝘂𝗽
After establishing the shared secret, SSH derives a symmetric session key. This key encrypts all subsequent
communication, providing both confidentiality (data remains private) and integrity (modifications are detected).
Symmetric encryption is computationally efficient, making it ideal for ongoing communication.
𝟰) 𝗖𝗹𝗶𝗲𝗻𝘁 𝗮𝘂𝘁𝗵𝗲𝗻𝘁𝗶𝗰𝗮𝘁𝗶𝗼𝗻
The client proves its identity through authentication methods, such as public key authentication. In this method, the
https://www.linkedin.com/feed/ 1/3
07/05/2025, 21:46 Feed | LinkedIn
client signs a server-provided challenge with its private key. The server verifies the signature using the client’s
public key, ensuring secure and tamper-proof authentication without exposing the private key.
💭 Over to you. Got any tips or stories about SSH to share? 💬
~~
Thanks to our partner AWS who keeps our content free to the community.
𝗗𝗲𝗽𝗹𝗼𝘆𝗶𝗻𝗴 𝗼𝗻 𝗔𝗪𝗦? Now you can ask your terminal things like: “𝗪𝗵𝘆 𝗶𝘀 𝗺𝘆 𝗟𝗮𝗺𝗯𝗱𝗮 𝗳𝗮𝗶𝗹𝗶𝗻𝗴?”
Check it out: https://lnkd.in/ggBeNFDe
https://www.linkedin.com/feed/ 2/3
07/05/2025, 21:46 Feed | LinkedIn
https://www.linkedin.com/feed/ 3/3