<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shalitharathnayaka on Medium]]></title>
        <description><![CDATA[Stories by Shalitharathnayaka on Medium]]></description>
        <link>https://medium.com/@shalithaRathnayakaa?source=rss-a4237e41d19c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OMcRVdoW349habOv</url>
            <title>Stories by Shalitharathnayaka on Medium</title>
            <link>https://medium.com/@shalithaRathnayakaa?source=rss-a4237e41d19c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:42:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shalithaRathnayakaa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Let’s Explore OSI Model]]></title>
            <link>https://medium.com/@shalithaRathnayakaa/lets-explore-osi-model-66b7bb3a10ae?source=rss-a4237e41d19c------2</link>
            <guid isPermaLink="false">https://medium.com/p/66b7bb3a10ae</guid>
            <category><![CDATA[osi-model]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[ip]]></category>
            <dc:creator><![CDATA[Shalitharathnayaka]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 14:15:17 GMT</pubDate>
            <atom:updated>2026-08-26T14:15:17.834Z</atom:updated>
            <content:encoded><![CDATA[<p>When you open a web browser, type <a href="https://google.com/"><strong>https://google.com</strong></a>, and press Enter, the process appears simple from a user’s perspective. Within a few seconds, the Google homepage is displayed. However, behind this simple action, many networking operations take place. Your computer must identify Google’s server, establish communication with it, prepare and transmit the request, route the data through several networks, receive the response, and finally deliver that response to your browser. The <strong>OSI (Open Systems Interconnection) model</strong> provides a conceptual framework that helps us understand how this communication takes place by dividing networking into seven different layers.</p><p>The seven layers of the OSI model are <strong>Application, Presentation, Session, Transport, Network, Data Link, and Physical</strong>. Each layer has a specific responsibility and works with the layers above and below it. When data is sent from your computer, it moves conceptually from the Application layer down toward the Physical layer. When the receiving system processes the information, the data moves in the opposite direction. This layered approach makes networking easier to understand because each layer focuses on a particular part of the communication process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sOB8iGj8hfrH99FvFg5NkQ.png" /></figure><h3>The OSI Model and Google.com</h3><p>Consider the following situation: you open Chrome and enter <a href="https://google.com/"><strong>https://google.com</strong></a>. Before your browser can retrieve Google’s webpage, it needs to determine where Google’s servers are located on the network. The first important step is therefore <strong>DNS resolution</strong>. Humans normally use domain names such as google.com, while network communication ultimately requires IP addresses. Your device sends a DNS query to a DNS resolver, which returns an appropriate IP address for the requested domain. Large services such as Google operate distributed infrastructure, so the exact IP address returned can vary depending on factors such as location and network conditions.</p><p>Once your computer has an IP address for the destination, your browser can begin establishing communication with the server. Because the URL uses <strong>HTTPS</strong>, the communication is protected using TLS. In traditional HTTPS over TCP, the client first establishes a TCP connection with the destination, normally using destination port <strong>443</strong>. TCP provides reliable, ordered communication between the client and server. After the connection and necessary security negotiation have been established, the browser can send its HTTP request.</p><p>The complete high-level journey can be represented as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S9fGTk5FisNN88IcyoANjw.png" /></figure><p>The OSI model allows us to look at this entire process layer by layer.</p><h3>Layer 7 — Application Layer</h3><p>The <strong>Application Layer</strong> is the highest layer of the OSI model and is closest to the applications that use network services. It provides protocols that applications use to communicate across a network. Common examples include HTTP, HTTPS, DNS, SMTP, FTP, SSH, and IMAP.</p><p>In the Google example, your browser uses <strong>HTTPS</strong> to communicate with Google’s web infrastructure. At the application level, the browser needs to request resources from Google. Conceptually, an HTTP request might contain information such as the requested path and the destination hostname. Google processes the request and eventually produces an HTTP response containing the resources required by the browser.</p><p>DNS is also commonly associated with Layer 7 because it is an application-level protocol. Before the HTTPS request can be sent, DNS can be used to resolve google.com into an IP address.</p><p>It is important to understand that Chrome itself is not “Layer 7.” Chrome is an application that uses Application-layer protocols such as HTTP and HTTPS.</p><h3>Layer 6 — Presentation Layer</h3><p>The <strong>Presentation Layer</strong> is responsible for how data is represented between communicating systems. Its conceptual responsibilities include data formatting, encoding, encryption, decryption, and compression. The purpose is to make sure that information can be represented and interpreted correctly by the communicating systems.</p><p>In the Google example, <strong>TLS</strong> is particularly important because HTTPS uses TLS to protect HTTP communication. TLS encrypts application data so that someone who intercepts the network traffic cannot simply read the protected content. The browser and server also perform cryptographic operations to establish the security parameters used during communication.</p><p>Although TLS is often discussed in relation to the Presentation layer, modern networking does not always implement protocols as perfectly separated OSI layers. TLS is better understood as a security protocol that operates around the application/transport boundary rather than something that must literally exist as a separate Layer 6 component.</p><h3>Layer 5 — Session Layer</h3><p>The <strong>Session Layer</strong> is responsible conceptually for establishing, maintaining, synchronizing, and terminating communication sessions between systems. It provides mechanisms that allow communication between two systems to be organized into a logical session.</p><p>For example, a communication process may need to establish a session, maintain that communication while data is exchanged, and eventually terminate it. The Session Layer provides a conceptual way of understanding these responsibilities.</p><p>In modern Internet networking, however, there is usually no independent protocol stack component that can simply be identified as “the Layer 5 protocol.” Many session-related responsibilities are handled by applications, libraries, operating systems, TLS, and transport protocols. Therefore, Layer 5 is best understood as a conceptual part of the OSI model rather than something you should expect to see explicitly in every network packet.</p><h3>Layer 4 — Transport Layer</h3><p>The <strong>Transport Layer</strong> is one of the most important layers when studying practical networking. Its main responsibility is to provide communication between applications or processes running on different hosts. The two major transport protocols are <strong>TCP</strong> and <strong>UDP</strong>.</p><p>For a traditional HTTPS connection, TCP is commonly used. TCP provides reliable and ordered delivery of data. Before application data is exchanged, TCP establishes a connection using its three-way handshake. The simplified process is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IuGtApBIawvwIZDxDE_Vhg.png" /></figure><p>TCP also uses <strong>port numbers</strong> to identify applications or services. HTTPS commonly uses destination port <strong>443</strong>. Therefore, when your browser communicates with a Google server, the communication can conceptually be represented as a connection between your computer’s temporary source port and the server’s port 443.</p><p>This gives us an important networking concept: an <strong>IP address identifies the destination host or network, while a port identifies a service or application endpoint on that host</strong>.</p><p>UDP is another Layer 4 protocol. Unlike TCP, UDP does not provide TCP’s connection-oriented reliability and ordering mechanisms. It is commonly used where low overhead and speed are important, including many DNS queries and real-time applications.</p><h3>Layer 3 — Network Layer</h3><p>The <strong>Network Layer</strong> is responsible primarily for logical addressing and routing. The most important protocol at this layer is IP, including IPv4 and IPv6.</p><p>Once DNS provides an IP address for Google’s service, your computer needs to send packets toward that destination. The destination may be many network hops away from your device. Your computer sends traffic toward its default gateway, and routers along the path examine the destination IP address and determine where the packet should be forwarded next.</p><p>Each router makes forwarding decisions based primarily on Layer 3 information. This is why routers are strongly associated with the Network Layer.</p><p>One important distinction is the difference between an IP address and a MAC address. An <strong>IP address is used for logical addressing and routing between networks</strong>, whereas a <strong>MAC address is primarily used for communication across the current local network link</strong>.</p><h3>Layer 2 — Data Link Layer</h3><p>The <strong>Data Link Layer</strong> is responsible for communication over a local network or network link. Important concepts at this layer include <strong>MAC addresses, Ethernet, Wi-Fi frames, switching, and local delivery</strong>.</p><p>When your computer needs to send a packet to another network, it first needs to deliver the packet to the appropriate next hop on its local network. For example, your laptop may communicate with your home router through Wi-Fi. The IP packet is placed inside a Layer 2 frame containing source and destination MAC addresses.</p><p>This is where the distinction between Layer 2 and Layer 3 becomes particularly important. The IP packet represents the Layer 3 communication, while the Layer 2 frame provides the local-link delivery mechanism.</p><p>A network switch primarily operates at Layer 2 and uses MAC addresses to make forwarding decisions within a local network.</p><p>An interesting aspect of the Google example is that the Layer 2 information can change as the packet moves through different network links. Your computer may communicate with your home router using one set of MAC addresses, while another link further along the path will have completely different Layer 2 addresses. This is because MAC addressing is associated with local network communication rather than end-to-end Internet routing.</p><h3>Layer 1 — Physical Layer</h3><p>The <strong>Physical Layer</strong> is the lowest layer of the OSI model. It is concerned with the actual transmission of bits through a physical medium.</p><p>Depending on how your computer is connected, the data may be transmitted using radio signals through Wi-Fi, electrical signals through copper Ethernet cables, or light pulses through fiber-optic cables.</p><p>At this layer, the abstract data eventually becomes physical signals representing bits.</p><p>The Physical Layer therefore includes concepts such as cables, connectors, radio transmission, electrical signaling, optical signaling, and other physical characteristics of network communication.</p><h3>Encapsulation: How the Request Is Prepared</h3><p>One of the most important concepts for understanding the OSI model is <strong>encapsulation</strong>. As data moves down the networking stack, each layer adds information required for its particular responsibility.</p><p>The browser starts with application data. The Transport Layer adds transport information such as TCP headers. The Network Layer adds IP information. The Data Link Layer adds frame information. Finally, the Physical Layer transmits the resulting information as signals.</p><p>Conceptually, the process looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ag52ODjQ4yCjHfzloST3DQ.png" /></figure><p>The receiving system performs the reverse process, known as <strong>de-encapsulation</strong>. It receives the physical signals, processes the frame, extracts the IP packet, processes the transport information, and eventually delivers the application data to the browser.</p><h3>Google’s Response</h3><p>After Google’s infrastructure receives the request, the process happens in the opposite direction. The server processes the incoming network information and eventually delivers the application request to the appropriate web service. The server then generates an HTTP response.</p><p>Conceptually, the response might contain an HTTP status such as 200 OK along with HTML and references to additional resources required to render the webpage.</p><p>The response then travels back toward your computer. At each network hop, the relevant networking mechanisms handle the traffic. When the response reaches your device, the information is de-encapsulated and eventually delivered to the browser.</p><p>The complete conceptual flow can therefore be represented as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nk1Jjjfav2TqB9Nq2nV9iA.png" /></figure><p>This diagram is simplified, but it captures the fundamental idea: <strong>the request moves down the networking stack on the sender, travels through the network, and is processed upward by the receiver; the response follows the reverse direction</strong>.</p><h3>Understanding the Google Request Through All Seven Layers</h3><p>If we combine everything, the Google request can be understood as follows. At <strong>Layer 7</strong>, the browser uses application protocols such as HTTPS and DNS. At <strong>Layer 6</strong>, data representation and cryptographic protection such as TLS are relevant. At <strong>Layer 5</strong>, session-related communication is conceptually managed. At <strong>Layer 4</strong>, TCP provides transport between the client and server and uses port 443 for HTTPS. At <strong>Layer 3</strong>, IP addresses and routing determine how packets travel between networks. At <strong>Layer 2</strong>, MAC addresses and Ethernet or Wi-Fi frames provide local-link delivery. Finally, at <strong>Layer 1</strong>, the information is transmitted as physical signals through Wi-Fi, copper, or fiber.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWChszWzXh7VTnFjLrERAA.png" /></figure><h3>Why the OSI Model Is Important</h3><p>The biggest value of the OSI model is not memorizing the seven layer names. Its real value is that it gives engineers a structured way to understand and troubleshoot network communication.</p><p>Suppose you cannot access a website. Instead of immediately assuming that the application is broken, you can investigate the communication systematically. You can first consider whether the physical connection is working, then whether the local network is functioning, then whether IP connectivity and routing are working, then whether the required TCP port is reachable, and finally whether the application protocol is responding correctly.</p><p>For example, if you can successfully reach an IP address but cannot establish a TCP connection to port 443, the problem is likely somewhere around the transport/network boundary rather than the HTTP application itself. If TCP port 443 is reachable but the HTTP request returns an error, the problem is more likely at the application level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66b7bb3a10ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSH Has a Public Key and a Private Key… But That’s Not the Whole Story!]]></title>
            <link>https://medium.com/@shalithaRathnayakaa/ssh-has-a-public-key-and-a-private-key-but-thats-not-the-whole-story-e0c6597a7388?source=rss-a4237e41d19c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0c6597a7388</guid>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[private-key]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[public-key-cryptography]]></category>
            <category><![CDATA[ssh-keys]]></category>
            <dc:creator><![CDATA[Shalitharathnayaka]]></dc:creator>
            <pubDate>Sat, 15 Aug 2026 18:41:46 GMT</pubDate>
            <atom:updated>2026-08-15T18:41:46.706Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have worked with Linux servers, DevOps tools, Git, or cloud infrastructure, you have probably used a command like:</p><pre>ssh user@server</pre><p>It looks simple. You enter one command, authenticate, and suddenly you have a terminal running on another machine.</p><p>But behind that single command is a carefully designed protocol involving <strong>TCP connections, cryptographic negotiation, key exchange, server verification, user authentication, encryption, and secure communication channels</strong>.</p><p>In this article, let’s look beyond the SSH command and understand what actually happens underneath.</p><h3>What Is SSH?</h3><p><strong>SSH (Secure Shell)</strong> is a cryptographic network protocol used to securely communicate with another computer over an untrusted network.</p><p>SSH is commonly used for:</p><ul><li>Remote server administration</li><li>Secure command execution</li><li>File transfers using SFTP/SCP</li><li>Port forwarding and tunneling</li><li>Git authentication</li><li>Infrastructure automation</li></ul><p>SSH normally operates over <strong>TCP port 22</strong>.</p><p>At a high level:</p><pre>Client                                   Server<br>┌──────────────┐                    ┌──────────────┐<br>│  SSH Client  │                    │  SSH Server  │<br>│              │                    │    sshd      │<br>└──────┬───────┘                    └──────┬───────┘<br>       │                                   │<br>       │       Untrusted Network           │<br>       └───────────────────────────────────┘</pre><p>SSH has to solve several security problems.</p><p>How does the client know it is communicating with the correct server?</p><p>How does the server know the user is authorized?</p><p>How can both machines communicate without someone reading or modifying their traffic?</p><p>That is where SSH’s cryptographic mechanisms come into play.</p><h3>1. Establishing the TCP Connection</h3><p>Before any SSH cryptography happens, the two machines need a network connection.</p><p>SSH normally runs on top of <strong>TCP</strong>, so the client first performs the standard TCP three-way handshake.</p><pre>Client                                  Server</pre><pre>   │ -------- SYN --------------------&gt; │<br>   │ &lt;------- SYN + ACK --------------- │<br>   │ -------- ACK --------------------&gt; │<br>   │                                    │<br>   │       TCP Connection Ready         │</pre><p>At this point, there is network connectivity between the two systems.</p><p>However, this does <strong>not</strong> mean the SSH session is secure yet.</p><p>Think of TCP as establishing the communication path. SSH then builds a secure communication system on top of that path.</p><h3>2. SSH Protocol Negotiation</h3><p>Once TCP is established, the SSH client and server exchange their protocol identification strings.</p><p>For example:</p><pre>Client:<br>SSH-2.0-OpenSSH_x.x</pre><pre>Server:<br>SSH-2.0-OpenSSH_x.x</pre><p>They then negotiate which cryptographic algorithms they will use.</p><p>This includes algorithms for:</p><ul><li>Key exchange</li><li>Server host authentication</li><li>Encryption</li><li>Integrity/authenticated encryption</li></ul><p>Modern SSH implementations may use algorithms such as:</p><pre>Key Exchange<br>    ↓<br>Curve25519</pre><pre>Server Authentication<br>    ↓<br>Ed25519 / ECDSA / RSA</pre><pre>Encryption<br>    ↓<br>AES / ChaCha20</pre><pre>Integrity<br>    ↓<br>AEAD or MAC mechanisms</pre><p>The exact combination depends on what both systems support and how they are configured.</p><h3>3. SSH Doesn’t Use Just One Key</h3><p>One of the biggest misunderstandings about SSH is thinking that there is simply an “SSH key.”</p><p>In reality, SSH may involve several categories of cryptographic keys.</p><pre>SSH<br>                      │<br>        ┌─────────────┼─────────────┐<br>        │             │             │<br>        ▼             ▼             ▼<br>    Host Keys      User Keys    Session Keys<br>        │             │             │<br>     Server          User          Protect<br>     Identity       Identity        Traffic</pre><p>Understanding these three categories makes SSH much easier to understand.</p><h3>Host Keys</h3><p>Host keys belong to the server.</p><p>They allow the client to verify:</p><blockquote><em>“Am I actually communicating with the server I intended to reach?”</em></blockquote><h3>User Keys</h3><p>User key pairs are commonly used to authenticate the user.</p><p>They answer:</p><blockquote><em>“Can this user prove they possess an authorized private key?”</em></blockquote><h3>Session Keys</h3><p>Session keys are temporary cryptographic keys created for the connection.</p><p>They protect the actual data travelling between the client and server.</p><p>These three types of keys have completely different responsibilities.</p><h3>4. Key Exchange — Creating a Shared Secret</h3><p>Now we reach one of the most interesting parts of SSH.</p><p>The client and server need encryption.</p><p>For efficient encrypted communication, they need shared cryptographic material.</p><p>But there is a problem.</p><p>They are communicating over an untrusted network.</p><p>Simply sending an encryption key across the network would be dangerous because an attacker could capture it.</p><p>SSH solves this through a <strong>key exchange algorithm</strong>, commonly using modern Diffie–Hellman-style mechanisms such as Curve25519.</p><p>Conceptually:</p><pre>CLIENT                                SERVER</pre><pre>Private value a                      Private value b<br>      │                                    │<br>      ▼                                    ▼<br>Public value A                       Public value B</pre><pre>      │ ----------- A ------------------&gt; │<br>      │                                   │<br>      │ &lt;---------- B ------------------- │</pre><pre>Calculate                            Calculate<br>shared secret K                     shared secret K</pre><p>Both machines independently arrive at shared secret material.</p><p>An attacker monitoring the connection may observe the public information being exchanged, but should not be able to feasibly calculate the resulting secret.</p><p>This allows two computers that have never communicated before to establish shared cryptographic material over an untrusted network.</p><h3>5. Authenticating the Server</h3><p>Key exchange alone is not enough.</p><p>Imagine an attacker positioning themselves between the client and server:</p><pre>Client  &lt;------&gt;  Attacker  &lt;------&gt;  Server</pre><p>The attacker could attempt to establish one encrypted connection with the client and another with the real server.</p><p>This is known as a <strong>Man-in-the-Middle (MITM) attack</strong>.</p><p>SSH addresses this using the server’s <strong>host key</strong>.</p><p>The server has a long-term host key pair:</p><pre>Server Host Key Pair<br>        │<br>   ┌────┴────┐<br>   ▼         ▼</pre><pre>Private    Public<br>  Key        Key</pre><p>The server uses its private host key to digitally sign relevant handshake data.</p><p>The client verifies that signature using the server’s public host key.</p><p>When connecting to a server for the first time, you may have seen:</p><pre>The authenticity of host cannot be established.</pre><pre>ED25519 key fingerprint is:<br>SHA256:...</pre><pre>Are you sure you want to continue connecting?</pre><p>When accepted, SSH normally records the server’s host key information in:</p><pre>~/.ssh/known_hosts</pre><p>On future connections, SSH compares the server’s presented identity against the stored information.</p><p>If the key unexpectedly changes, SSH can display a warning.</p><p>This mechanism helps detect situations where the server identity is not what the client expects.</p><h3>6. Creating Session Keys</h3><p>After the authenticated key exchange, SSH derives temporary <strong>session keys</strong>.</p><p>Conceptually:</p><pre>Shared Secret<br>      │<br>      ▼<br>Key Derivation<br>      │<br>      ├── Client → Server key<br>      │<br>      ├── Server → Client key<br>      │<br>      └── Additional cryptographic state</pre><p>These keys are then used to protect the actual SSH connection.</p><p>This is an important distinction:</p><p><strong>Your SSH private key is not normally used to directly encrypt every command you send.</strong></p><p>Instead, SSH combines asymmetric cryptographic mechanisms for authentication/key establishment with fast symmetric cryptography for protecting the actual session.</p><h3>7. Why Symmetric Encryption?</h3><p>Public-key cryptography is powerful, but it is relatively expensive for bulk data processing.</p><p>Symmetric encryption is much faster.</p><p>Therefore SSH essentially follows this model:</p><pre>Asymmetric Cryptography<br>          │<br>          ▼<br>Authentication +<br>Authenticated Key Establishment<br>          │<br>          ▼<br>Session Keys<br>          │<br>          ▼<br>Symmetric Encryption<br>          │<br>          ▼<br>Actual SSH Communication</pre><p>Modern SSH can use encryption mechanisms based on algorithms such as <strong>AES</strong> or <strong>ChaCha20-Poly1305</strong>.</p><p>Now the client and server have an encrypted and integrity-protected transport.</p><p>But there is still another question:</p><p><strong>Who is the user?</strong></p><h3>8. User Authentication</h3><p>After establishing the secure transport, the SSH server authenticates the user.</p><p>SSH supports several authentication mechanisms, including:</p><ul><li>Password authentication</li><li>Public-key authentication</li><li>SSH certificates</li><li>Hardware-backed authentication</li><li>Keyboard-interactive authentication</li></ul><p>Public-key authentication is one of the most common methods.</p><p>A user can generate a key pair using a command such as:</p><pre>ssh-keygen -t ed25519</pre><p>This produces a private key and a public key.</p><pre>SSH Key Pair<br>                  │<br>          ┌───────┴───────┐<br>          ▼               ▼</pre><pre>     Private Key       Public Key<br>         │                 │<br>      Secret            Shareable<br>         │                 │<br>      Client             Server</pre><p>The private key should remain protected on the client machine.</p><p>The public key can be placed on the server.</p><p>For a Linux user, authorized public keys are commonly stored in:</p><pre>~/.ssh/authorized_keys</pre><h3>9. Your Private Key Is Not Sent to the Server</h3><p>This is probably the most important concept in SSH public-key authentication.</p><p>When you authenticate, your private key is <strong>not uploaded or transmitted to the server</strong>.</p><p>Instead, the client proves that it possesses the private key.</p><p>It does this using a <strong>digital signature</strong>.</p><p>Conceptually:</p><pre>Client                              Server</pre><pre>Private Key                         Public Key<br>    │                                   │<br>    ▼                                   │<br>Create Signature                        │<br>    │                                   │<br>    └────── Signature ────────────────&gt; │<br>                                        │<br>                                        ▼<br>                                  Verify Signature<br>                                        │<br>                                  ┌─────┴─────┐<br>                                  ▼           ▼<br>                                Valid       Invalid</pre><p>The server can verify the signature using the authorized public key.</p><p>If verification succeeds, the server obtains cryptographic proof that the client possesses the corresponding private key.</p><p>The private key itself never needs to cross the network.</p><h3>0. The Secure SSH Session</h3><p>Once the server successfully authenticates the user, SSH can create one or more logical channels inside the secure connection.</p><p>SSH is not limited to interactive terminals.</p><p>It can support:</p><pre>SSH Connection<br>                      │<br>        ┌─────────────┼─────────────┐<br>        ▼             ▼             ▼</pre><pre>   Interactive     Command         SFTP<br>      Shell       Execution</pre><pre>                      │<br>                      ▼</pre><pre>               Port Forwarding</pre><p>This is why SSH can be used for much more than simply logging into another Linux machine.</p><h3>11. What Happens When You Type ls?</h3><p>Suppose you are connected to a server and type:</p><pre>ls</pre><p>From your perspective, the command appears instantly on the remote terminal.</p><p>Internally, something closer to this happens:</p><pre>Keyboard<br>   │<br>   ▼<br>Terminal<br>   │<br>   ▼<br>SSH Client<br>   │<br>   ▼<br>SSH Channel<br>   │<br>   ▼<br>Encrypt / Authenticate<br>   │<br>   ▼<br>TCP<br>   │<br>   ▼<br>Network<br>   │<br>   ▼<br>TCP<br>   │<br>   ▼<br>SSH Server<br>   │<br>   ▼<br>Decrypt / Verify<br>   │<br>   ▼<br>SSH Channel<br>   │<br>   ▼<br>Remote Shell<br>   │<br>   ▼<br>Execute &quot;ls&quot;</pre><p>The output travels back through the secure connection in the opposite direction.</p><p>Someone monitoring the network should therefore not simply see:</p><pre>ls<br>cd /home<br>cat file.txt</pre><p>They see protected SSH traffic.</p><h3>Although encryption and authentication work together in SSH, they serve <strong>different security purposes</strong>.</h3><h3>Encryption — Protecting the Data</h3><p>Encryption ensures that information exchanged between the client and server remains <strong>confidential</strong>. SSH uses negotiated session keys and symmetric encryption so intercepted network traffic cannot be easily read by an attacker.</p><h3>Server Authentication — Verifying the Server</h3><p>Server authentication allows the SSH client to <strong>verify the identity of the remote server</strong>. SSH uses the server’s host key for this purpose, helping protect the connection against impersonation and Man-in-the-Middle attacks.</p><h3>User Authentication — Verifying the User</h3><p>After establishing a secure connection, the server needs to verify that the connecting user is <strong>authorized to access the system</strong>. SSH can perform this using public-key authentication, passwords, SSH certificates, and other supported methods.</p><h3>Integrity and Authenticity — Protecting Against Modification</h3><p>SSH also ensures that transmitted data cannot be <strong>silently modified or forged</strong> while travelling across the network. Modern SSH cryptographic mechanisms detect unauthorized changes to protected traffic.</p><p>In simple terms:</p><p><strong>Encryption protects the data → Server authentication verifies the server → User authentication verifies the user → Integrity protects the communication from tampering.</strong>13. The Complete SSH Flow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7JtnS6f0OYv76ubxas0Yw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0c6597a7388" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>