SSH (Secure Shell)

A network protocol that lets you securely log into a remote computer and run commands on it, as if you were sitting right in front of it — with all communication encrypted so nobody can eavesdrop.


What is SSH?

Every server that powers a website, runs an application, or stores data needs to be managed. Someone has to install software, update configurations, check logs, and fix problems. But these servers are rarely in the same room as the person managing them — they could be in a data centre on another continent.

SSH (Secure Shell) is the protocol that makes this possible. It creates an encrypted tunnel between your computer (the client) and a remote machine (the server), allowing you to type commands on the remote machine as though you were physically there. Everything that travels through this tunnel — your password, your commands, the output you see — is encrypted, which means anyone intercepting the traffic sees meaningless noise.1

SSH was created in 1995 by Finnish researcher Tatu Ylonen after a password-sniffing attack at his university. Before SSH, the standard tool for remote access was Telnet, which sent everything — including passwords — in plain text across the network. SSH replaced Telnet by solving one critical problem: making remote access secure by default.2

Today, SSH is the standard way to manage servers, transfer files, and automate deployment pipelines. If you have ever typed ssh user@server.com in a terminal, you have used it.

In plain terms

SSH is like making a phone call through a soundproof, private line. You dial the remote computer, prove who you are, and then have a private conversation where you give instructions and hear results — and nobody else on the network can listen in.


At a glance


How does SSH work?

An SSH connection happens in three phases: transport, authentication, and session. Each phase solves a different problem.

1. Transport — establishing encryption

When you type ssh user@server.com, your computer opens a TCP connection to port 22 on the server. Before any sensitive data is exchanged, the two machines agree on how to encrypt the session.3

This negotiation uses a technique called the Diffie-Hellman key exchange — a method that allows two parties to agree on a shared secret over an insecure channel without ever sending the secret itself. The result is a session key: a symmetric encryption key that both sides use to encrypt and decrypt all traffic for this session.3

The server also presents its host key — a public key that identifies the server. The first time you connect to a server, your client stores this key. On future connections, it compares the server’s key to the stored one. If they don’t match, SSH warns you that someone might be impersonating the server (a “man-in-the-middle” attack).1

Think of it like...

Two people meeting in a crowded room who need to agree on a secret code word. Diffie-Hellman is the clever trick that lets them do this by shouting partial clues back and forth — even though everyone in the room can hear the clues, only the two of them can combine them into the final code word.


2. Authentication — proving who you are

Once the encrypted tunnel is established, the server needs to verify that you are who you claim to be. SSH supports two main methods:

Password authentication. The simplest method: you type your password, and it travels through the encrypted tunnel to the server. The server checks it against its user database. This works, but it is vulnerable to brute-force attacks if the password is weak.

Key-based authentication. The more secure method. You generate a key pair: a private key (stays on your computer, never shared) and a public key (placed on the server). When you connect, the server sends a challenge encrypted with your public key. Only your private key can decrypt it, proving your identity without ever sending a password.4

MethodSecurityConvenienceBest for
PasswordModerate — depends on password strengthSimple setupQuick access, temporary servers
Key pairHigh — nearly impossible to brute-forceRequires initial setupProduction servers, automation

Concept to explore

See ssh-keys for a deeper dive into key generation, key types (RSA vs ed25519), and key management best practices.


3. Session — working on the remote machine

After authentication, you have an interactive terminal session on the remote server. Every keystroke you type is encrypted, sent through the tunnel, executed on the server, and the output is encrypted and sent back to your screen.

But SSH is not limited to interactive terminals. A single SSH connection can carry multiple channels, each doing something different:1

  • Shell session — an interactive command line
  • Command execution — run a single command and get the result (e.g., ssh server "df -h" to check disk space)
  • File transfer — SCP and SFTP use SSH as their transport layer
  • Port forwarding — tunnel other network traffic through the encrypted SSH connection

Concept to explore

See ssh-tunneling for how port forwarding lets you securely access services behind firewalls, and scp-sftp for file transfer over SSH.


Why do we use SSH?

Key reasons

1. Encryption by default. Every byte of communication is encrypted. Unlike older protocols (Telnet, rlogin), there is no way to accidentally send data in plain text. This protects passwords, commands, and output from eavesdropping.2

2. Strong authentication. Key-based authentication is virtually immune to brute-force attacks. A 256-bit ed25519 key would take longer than the age of the universe to crack with current technology.5

3. Versatility. SSH is not just for typing commands. It transfers files (SCP/SFTP), forwards ports (tunneling), and serves as the transport layer for tools like Git, Ansible, and rsync.1

4. Universal availability. SSH comes pre-installed on Linux, macOS, and (since 2018) Windows 10. Every cloud provider supports it. It is the lingua franca of server management.


When do we use SSH?

  • When managing remote servers — deploying code, reading logs, restarting services, configuring software
  • When transferring files securely between machines (using SCP or SFTP)
  • When pushing code to Git repositories (GitHub, GitLab, and Bitbucket all support SSH authentication)
  • When automating infrastructure — tools like Ansible and Terraform use SSH to configure remote machines
  • When you need to access a service behind a firewall by tunneling traffic through an SSH connection
  • When setting up CI/CD pipelines that need to deploy to production servers

Rule of thumb

If you need to interact with a remote machine securely — whether to run commands, transfer files, or tunnel traffic — SSH is almost certainly the right tool.


How can I think about SSH?

The diplomatic pouch

In international diplomacy, sensitive documents travel in diplomatic pouches — sealed bags that cannot be opened or inspected by anyone except the sender and recipient.

  • Your computer is the embassy sending the pouch
  • The server is the embassy receiving it
  • The SSH tunnel is the diplomatic pouch — sealed and tamper-proof
  • Your commands are the documents inside
  • The key exchange is the diplomatic agreement that establishes the secure channel
  • Key-based authentication is showing your diplomatic credentials to prove you are authorised to send pouches

Anyone can see that a pouch was sent, but nobody can read what is inside.

The bank vault phone

Some bank vaults have a direct phone line between the vault and the manager’s office — no switchboard, no shared line, completely private.

  • Your terminal is the manager’s office
  • The server is the vault
  • The SSH connection is the direct phone line — private and dedicated
  • Password authentication is like giving a verbal password over the line
  • Key authentication is like the line only activating when the manager presses a physical key that matches the vault’s lock
  • Port forwarding is like letting a colleague use the manager’s phone to talk to the vault on their behalf

Concepts to explore next

ConceptWhat it coversStatus
ssh-keysKey generation, types (RSA, ed25519), key managementstub
ssh-tunnelingPort forwarding, jump hosts, accessing firewalled servicesstub
scp-sftpTransferring files securely over SSHstub
public-key-cryptographyThe mathematical foundation behind SSH authenticationstub

Some of these cards don't exist yet

They’ll be created as the knowledge system grows. A broken link is a placeholder for future learning, not an error.


Check your understanding


Where this concept fits

Position in the knowledge graph

graph TD
    SA[Software Architecture] --> CSM[Client-Server Model]
    CSM --> SSH[SSH]
    CSM --> HTTP[HTTP Protocol]
    SSH --> SK[SSH Keys]
    SSH --> ST[SSH Tunneling]
    SSH --> SF[SCP / SFTP]
    style SSH fill:#4a9ede,color:#fff

Related concepts:

  • client-server-model — SSH is a client-server protocol; the SSH client connects to an SSH daemon (server) listening on port 22
  • apis — while APIs define how software components talk to each other, SSH defines how humans and tools securely talk to machines

Sources


Further reading

Resources

Footnotes

  1. Cloudflare. What is SSH? | Secure Shell (SSH) protocol. Cloudflare Learning Center. 2 3 4

  2. Wikipedia contributors. Secure Shell. Wikipedia. 2

  3. DigitalOcean. Understanding the SSH Encryption and Connection Process. DigitalOcean Community Tutorials. 2

  4. phoenixNAP. How Does SSH Work?. phoenixNAP Knowledge Base.

  5. Checketts, B. (2025). SSH Key Best Practices for 2025. Brandon Checketts.