>_ SSHDock
FeaturesHow it worksBlogGuidesAbout
Launch Terminal
Back to Journal

What is SSH and how does it work?

AH
Ayan Hussain
Dec 30, 2025 · 6 min read

On this page

  • Before SSH: the Telnet era
  • What happens when you connect
  • Password vs key authentication
  • How SSH handles multiple connections
  • Port forwarding and tunneling
  • File transfer over SSH
  • The sshd config file
  • Accessing SSH from a browser

SSH stands for Secure Shell. It is a protocol for logging into a remote computer and running commands on it, over an encrypted connection. If you manage a Linux server, you almost certainly use it already. If you are new to server administration, it is the first thing to understand.

Here is how it actually works.

Before SSH: the Telnet era

Before SSH, the standard way to access a remote server was Telnet. Telnet sends everything as plain text: your username, your password, every command you type, every line the server sends back. Anyone monitoring the network between you and the server can read all of it verbatim.

In 1994, a researcher at the Helsinki University of Technology named Tatu Ylönen discovered that a password sniffer had been installed on his university's network. It had collected over 200 usernames and passwords from Telnet and FTP sessions. He spent the next few months writing a replacement protocol and released it publicly in 1995 as SSH (Secure Shell).

SSH encrypts the entire connection, including authentication. An attacker watching your network traffic sees only encrypted bytes. The only meaningful information they can observe is that an SSH connection happened and roughly how much data was transferred.

What happens when you connect

When you run ssh user@host, a sequence of steps happens before you ever see a prompt. Understanding these steps makes it much easier to diagnose connection problems and reason about what is actually happening.

Step 1: TCP connection. Your client connects to the server on port 22 (or whatever port SSH is configured to use). Port 22 is the IANA-assigned default.

Step 2: Protocol version exchange. Both sides announce which version of the SSH protocol they support. SSH-1 and SSH-2 are the major versions. Everything modern uses SSH-2. SSH-1 had cryptographic weaknesses and is disabled in current implementations.

Step 3: Algorithm negotiation. Both sides exchange lists of encryption, MAC (message authentication code), and key exchange algorithms they support. They agree on the most preferred option both sides have in common. This is why very old servers sometimes fail to connect with modern clients: the algorithm sets no longer overlap.

Step 4: Key exchange (Diffie-Hellman). This is the clever part. Both sides run a mathematical protocol called Diffie-Hellman key exchange that allows them to arrive at the same shared secret without ever transmitting that secret. An observer watching all of the key exchange traffic cannot compute the shared secret from what they see. At the end of this step, both sides hold an identical symmetric key that no one else has.

Step 5: All further communication is encrypted. From this point on, everything is encrypted with the shared key using a symmetric cipher (commonly AES-256 in GCM or CTR mode).

Step 6: Server authentication (host key). The server sends its host key, which is a public key that identifies this specific server. Your client checks this against the known hosts file (~/.ssh/known_hosts). If you have never connected to this server before, SSH shows you the fingerprint and asks if you trust it. If you say yes, it stores the fingerprint. If you connect again later and the fingerprint has changed, SSH warns you and refuses to connect by default, because a changed fingerprint is a sign that something might be wrong (a server reinstall, a DNS change, or a man-in-the-middle attack).

Step 7: User authentication. You prove who you are. Either with a password or with key-based authentication. If authentication succeeds, you get a shell.

Password vs key authentication

Password authentication is what it sounds like. You type a password; the server verifies it against the system's password database. This is fine for getting started but has problems at scale: passwords can be leaked, guessed, or phished, and any server with port 22 public gets hit by bots testing common credentials constantly.

Key-based authentication is more secure and more convenient once it is set up. You generate a key pair: a private key that stays on your machine and a public key that you put on the server in ~/.ssh/authorized_keys. When you connect, the server issues a cryptographic challenge encrypted with your public key. Your client decrypts it locally with your private key and sends back a signed response. The server verifies the signature. Your private key never crosses the network.

An automated bot trying password combinations cannot touch this. There is no password to guess. Our SSH key authentication guide covers the full setup process.

How SSH handles multiple connections

Each SSH session is a separate encrypted channel. Within a single SSH connection, you can also open additional channels:

  • Shell channels: what you get when you log in normally
  • Exec channels: for running a single command without an interactive shell (ssh user@host ls -la)
  • Subsystem channels: used for SFTP
  • Port forwarding channels: for tunneling other TCP traffic

This multiplexing is why tools like rsync and git can use SSH under the hood without you doing anything special. They open a channel to execute a specific command on the remote end.

Port forwarding and tunneling

The encrypted tunnel SSH creates can carry things besides terminal sessions. Port forwarding is the most commonly used capability.

Local port forwarding lets you access a service on the remote network that is not publicly exposed:

ssh -L 5432:db.internal:5432 user@bastion

This makes your local port 5432 connect through to the database server. Your local database client talks to a remote database without that database ever being on the internet.

Remote port forwarding lets you expose a local service through the remote server:

ssh -R 8080:localhost:3000 user@remote

Anyone visiting port 8080 on the remote server gets your local port 3000.

Dynamic forwarding creates a SOCKS proxy, letting you route all browser traffic through the SSH connection. Our port forwarding guide covers all three types with examples.

File transfer over SSH

SSH includes two protocols for file transfer: SCP and SFTP. Both run inside an SSH connection and inherit its encryption.

SCP (Secure Copy) is a simple protocol for copying files. It is being deprecated in favor of SFTP in many implementations because it has some edge cases with special characters in filenames.

SFTP (SSH File Transfer Protocol) is a full file management protocol, not just copying. You can list directories, rename files, delete files, and set permissions. It is what graphical SFTP clients like FileZilla, Cyberduck, and WinSCP use under the hood.

Our SCP and SFTP guide covers both in more detail.

The sshd config file

On the server, the SSH daemon's behavior is controlled by /etc/ssh/sshd_config. This file is where you:

  • Change the default port (from 22 to something else, to reduce automated scan noise)
  • Disable password authentication (PasswordAuthentication no)
  • Restrict which users can log in (AllowUsers)
  • Set session timeouts (ClientAliveInterval, ClientAliveCountMax)
  • Configure which key exchange and encryption algorithms to allow

Changes to this file require reloading the daemon to take effect: sudo systemctl reload sshd. Our SSH hardening guide covers the most important settings.

Accessing SSH from a browser

If you are on a device without a native SSH client, including Chromebooks, iPads, and managed corporate machines where you cannot install software, SSHDock provides a full SSH terminal that runs entirely in the browser. The encryption happens on your device; the browser connects directly to the server. No installation required.

For more on securing the server itself once you can connect, see our guide on how to secure an SSH server.

AH
Written by
Ayan Hussain

Full-Stack Developer and creator of SSHDock. Ayan builds browser-based developer tools and writes about SSH security, Linux server management, and modern web engineering.

About meGitHub

Keep reading

May 20, 2026

What is a bastion host?

A bastion host is a server that sits on the boundary between a private network and the internet. Here is what it does, why it exists, how to configure one, and when to consider alternatives.

Jan 21, 2026

What is an SSH key? How it works and how to generate one

SSH keys replace passwords for server authentication. Here is what they are, how the cryptography works, how to generate one in two minutes, and what to do if something goes wrong.

Oct 6, 2026

How to Fix 'WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!'

Why you get the scary StrictHostKeyChecking warning in SSH, what a man-in-the-middle attack looks like, and how to safely clear out old known_hosts entries.

SSHDOCK

Full terminal in your browser. Local credential storage, jump host tunneling, live CPU/memory/disk metrics, and a mobile soft-key bar. Free to use. Built by developers, for developers.

© 2026 SSHDock

GitHub (@ayanhackspro)
App
Launch TerminalFeaturesHow it worksBlog & TutorialsChangelogGuides
Cloud Guides
AWS EC2DigitalOcean DropletGoogle Cloud Compute EngineMicrosoft Azure Virtual MachineLinode Compute InstanceVultr Cloud Compute
Legal & Contact
Privacy PolicyTerms of ServiceDisclaimerContact UsAbout Creator
Modern, minimal browser SSH client
TerminalSitemap