Understanding SSH: How Secure Shell Works, Ports, and Key Authentication

This article explains the SSH protocol, covering its default port, the step-by-step connection process—including version and algorithm negotiation, key exchange, and user authentication—along with practical guidance on using PuTTY, OpenSSH, and SSH key management.

Open Source Linux
Open Source Linux
Open Source Linux
Understanding SSH: How Secure Shell Works, Ports, and Key Authentication

SSH (Secure Shell) is a network security protocol that provides encrypted and authenticated access for remote login and file transfer, replacing insecure methods such as Telnet and FTP.

Table of Contents

What is the SSH port number? How does SSH work? Using PuTTY and OpenSSH

What is the SSH Port Number?

The default SSH port is 22 for protocols like SSH, SFTP, and SCP. For NETCONF, the port can be 22 or 830. The port can be changed, which disconnects existing sessions and makes the server listen on the new port.

How Does SSH Work?

SSH consists of a client and a server. The connection establishment involves several stages:

Connection Establishment

The SSH server listens on a specified port for client connection requests. After the client initiates a request, a TCP connection is formed.

Version Negotiation

SSH supports SSH1.X (pre‑SSH2.0) and SSH2.0. SSH2.0 adds support for more authentication and key‑exchange methods. The client and server negotiate the protocol version to use.

Algorithm Negotiation

Both sides agree on the key‑exchange algorithm, encryption algorithm, public‑key algorithm, and HMAC algorithm that will be used to secure the session.

Key Exchange

Using the agreed key‑exchange algorithm, the client and server generate a shared session key and session ID, establishing an encrypted channel.

User Authentication

The client authenticates to the server. SSH supports several authentication methods:

Password authentication: the client sends an encrypted username and password.

Public‑key authentication: the client uses a public‑key pair.

Password‑public‑key authentication: both password and key are required.

Any authentication: either password or key is sufficient.

Session Request

After successful authentication, the client requests a specific service (e.g., a shell) from the server.

Session Interaction

Once the session is established, the client and server exchange data over the encrypted channel.

Using PuTTY and OpenSSH

PuTTY is a classic free SSH client for Windows, available from the official website.

OpenSSH is the open‑source implementation of SSH for Unix‑like systems. Windows 10 includes OpenSSH client and server as optional features.

SSH Keys

Symmetric and Asymmetric Encryption

SSH combines symmetric and asymmetric encryption. Symmetric encryption uses a single key for both encryption and decryption, providing fast data transfer. Asymmetric encryption uses a public‑key/private‑key pair, enhancing security during key exchange and authentication.

Key Authentication

SSH supports password and key authentication. Key authentication uses a public‑key pair to verify the client without transmitting a password, enabling secure password‑less login.

The client generates a public‑key/private‑key pair and stores the public key on the server.

The server encrypts a random challenge with the stored public key and sends it to the client.

The client decrypts the challenge with its private key and returns the response.

The server verifies the response; if correct, authentication succeeds.

Encryptionnetwork securitySSHOpenSSHkey authenticationSecure ShellPutty
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.