SSH (Secure Shell) is an encrypted network protocol for logging into a remote computer and running commands on it, usually over TCP port 22. It stops anyone on the network from reading your passwords, commands or files, and it checks who the server is and who you are. Developers use it daily to manage servers and push code.
Before you start: no earlier post is needed. You only need a terminal. Linux and Mac have one built in, and Windows 10 and 11 can use PowerShell once the OpenSSH client is on.
Tested with OpenSSH 10.0p2 on Debian 13. The connection examples ran against a small local practice server on port 2222, not a production OpenSSH server, so a real server’s banner text may differ slightly. Everything shown below is real output unless marked.
What is the full form of SSH?
SSH stands for Secure Shell. You will also see it called the Secure Shell protocol or the Secure Shell Protocol, and GitHub’s own documentation writes it as “SSH (Secure Shell Protocol)”. The “shell” is the text interface where you type commands. The “secure” part is the encryption wrapped around it.
The protocol’s current form, SSH version 2, was published as a set of standards in January 2006: RFC 4251 (architecture), RFC 4252 (authentication), RFC 4253 (transport) and RFC 4254 (connection). If an exam asks for the full form, “Secure Shell” is the answer. If it asks what SSH does, the one-line version is “a secure replacement for Telnet and other plain-text remote login tools”.
What is the SSH protocol in computer networks?
SSH is an application-layer protocol that runs on top of TCP. A client program (the machine you sit at) connects to a server program (the machine you want to control). The standard splits the protocol into three layers, and this is the part most exam questions ask for:
| Layer | What it does | Defined in |
|---|---|---|
| Transport layer | Sets up the connection, negotiates algorithms, exchanges keys, authenticates the server, then encrypts and integrity-checks everything | RFC 4253 |
| User authentication layer | Proves who the user is (public key, password or host-based) | RFC 4252 |
| Connection layer | Splits one encrypted connection into several channels: a terminal session, a command, a forwarded port | RFC 4254 |
The overall design is in RFC 4251. The software you actually use is usually OpenSSH, the open-source implementation that ships with Linux, macOS and Windows. Its tools are ssh (the client), sshd (the server), ssh-keygen, ssh-agent, ssh-add, scp and sftp. Microsoft’s OpenSSH overview lists the same set for Windows.
How does SSH work step by step?
Here is the whole handshake in one picture. Read it top to bottom.
YOU (client) SERVER (sshd, port 22)
| |
|---- 1. TCP connection to port 22 ----------------->|
|<--- 2. Version banners: SSH-2.0-... ---------------|
| |
|<--- 3. Algorithm lists, key exchange (hybrid) ---->| both sides now share
| + server proves its identity (host key) | a secret key
| |
|========= everything below is encrypted ===========|
| |
|---- 4. User authentication (key or password) ---->|
|<--- success -------------------------------------- |
|---- 5. Open a channel: shell or command ---------->|
|<--- output, typed input, files (encrypted) ------->|Step 1: TCP connection. Your client opens an ordinary TCP connection to the server, normally on port 22.
Step 2: Version exchange. Each side sends a one-line banner naming the protocol version and its software, in the form SSH-2.0-software. This is real, from our run:
Local version string SSH-2.0-OpenSSH_10.0p2 Debian-7+deb13u4
Remote protocol version 2.0, remote software version AsyncSSH_2.24.2Step 3: Key exchange and server authentication. The two sides agree on algorithms, then run a key exchange to create a secret that only they know, without ever sending that secret over the wire. The server also signs part of the exchange with its host key, which proves it is the machine you meant to reach. In OpenSSH 10 the default key exchange is a hybrid called mlkem768x25519-sha256, which we cover in the next section. Here is the real negotiation from ssh -v:
kex: algorithm: mlkem768x25519-sha256
kex: host key algorithm: ssh-ed25519
kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
Server host key: ssh-ed25519 SHA256:/GGeym8oK18GELjVgWfxW/eGXPTeBZtISgbPVBK01XkFrom this point the traffic is encrypted. The cipher shown, ChaCha20-Poly1305, encrypts and authenticates the data in one go.
Step 4: User authentication. Now the server asks who you are. The server told our client which methods it accepts, and our client offered a key:
Authentications that can continue: publickey
Offering public key: demo_key ED25519 SHA256:FY60YsAtnlfiH2QNd5Mi1qbvLP8X52co2zHY7/FX25w explicit
Server accepts key: demo_key ED25519 SHA256:FY60YsAtnlfiH2QNd5Mi1qbvLP8X52co2zHY7/FX25w explicit
Authenticated to 127.0.0.1 ([127.0.0.1]:2222) using "publickey".Step 5: The session. The connection layer opens a channel for your shell, or for one command, or for a forwarded port. Several channels can share the same encrypted connection, which is why SSH can carry a terminal and a port forward together.
What happens the first time you connect to a server?
Your client has never seen this host key before, so it asks you to check it. This is the real prompt:
The authenticity of host '[127.0.0.1]:2222 ([127.0.0.1]:2222)' can't be established.
ED25519 key fingerprint is SHA256:Y1vUjAMpEB6+wQc7UNGOm0EhqlCdhAopY5iQl53xvtQ.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?If you answer yes, the key is saved in ~/.ssh/known_hosts. Next time, the client compares the key it receives with the saved one. If they differ, SSH stops you, as shown in the errors section below. That check is what protects you from someone pretending to be your server.
What changed in SSH going into 2027? Post-quantum key exchange
Hybrid post-quantum key exchange is not a 2027 feature: it became the OpenSSH default in version 10.0, back in April 2025. The newest change is from October 2026, when OpenSSH 10.6 added the WarnWeakCrypto option to the server config. Key exchange is the part of SSH that matters most for privacy. If an attacker breaks it, they can decrypt the whole session. The risk the OpenSSH team describes is “store now, decrypt later”: someone records encrypted traffic today and decrypts it once quantum computers are strong enough. The OpenSSH post-quantum page says such computers have not been built yet, and it recommends that all connections use post-quantum key agreement now.
OpenSSH’s answer is a hybrid: it combines a post-quantum algorithm (ML-KEM) with the classical X25519 exchange. The page explains that the hybrid is no worse than the classical algorithm even if the new part were broken. Here is the timeline from the official notes:
| OpenSSH version | Date | Change |
|---|---|---|
| 9.0 | April 2022 | sntrup761x25519-sha512 hybrid becomes the default |
| 9.9 | 2024-09-19 | mlkem768x25519-sha256 added |
| 10.0 | 2025-04-09 | mlkem768x25519-sha256 becomes the default; DSA support removed |
| 10.1 | 2025-10-06 | Client warns when a connection is not post-quantum (WarnWeakCrypto) |
| 10.4 | 2026-07-06 | Experimental post-quantum signature scheme mldsa44-ed25519 added, off by default |
| 10.6 | 2026-10-06 | WarnWeakCrypto also added to sshd_config; scp -R begins deprecation |
| 10.6p2 | 2026-11-05 | Latest release at the time of writing; includes a security fix |
The OpenSSH release notes also say the team is now making more frequent releases. So check the release notes for the current number. The 10.6p2 notes mention one security fix, a password authentication bypass that affects some Linux systems built and run with PAM disabled (musl libc), so it does not touch most desktop setups. Linux distributions often ship older builds with backported fixes, so ask your package manager, not just the version number.
You can see what your own client supports. Here is the list from our machine:
ssh -Q kexdiffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group14-sha256
diffie-hellman-group16-sha512
diffie-hellman-group18-sha512
diffie-hellman-group-exchange-sha1
diffie-hellman-group-exchange-sha256
ecdh-sha2-nistp256
ecdh-sha2-nistp384
ecdh-sha2-nistp521
curve25519-sha256
curve25519-sha256@libssh.org
sntrup761x25519-sha512
sntrup761x25519-sha512@openssh.com
mlkem768x25519-sha256If you ever see this warning, the server you connected to did not offer a post-quantum algorithm. The fix is to update the server, as the OpenSSH page advises:
** WARNING: connection is not using a post-quantum key exchange algorithm.
** This session may be vulnerable to "store now, decrypt later" attacks.
** The server may need to be upgraded. See https://openssh.com/pq.html(That text is quoted from the OpenSSH page. We did not trigger it on our test machine.)
How does SSH authentication work? Password vs key
After the encrypted channel exists, the server decides whether to let you in. RFC 4252 defines three methods: public key, password and host-based. Public key is the only one the standard requires every server to support. In everyday use, you meet two.
Password authentication. You type your account password. It travels inside the encrypted channel, so it is not visible on the network. But it can still be guessed, reused or phished, and servers that face the internet are often probed with password guesses.
Public key authentication. You create a key pair: a private key that stays on your computer and a public key you put on the server. When you log in, your client signs data that includes the session identifier with the private key, and the server checks that signature against the public key. The private key itself never leaves your machine, so there is no password to steal in transit.
| Password | Public key | |
|---|---|---|
| What you prove | You know a secret | You hold a private key |
| What crosses the network | The password (encrypted) | A signature, never the key |
| Brute-force guessing | Possible | Not practical for a modern key |
| Setup effort | None | One-time key creation and copy |
| Works well for scripts | Poorly | Yes |
| Recommended for servers | Only as a fallback | Yes |
Whichever you use, SSH first authenticates the server with the host key (step 3), then authenticates you. Both directions are checked.
What port does SSH use?
SSH uses TCP port 22. RFC 4253 states that the port is registered with IANA, and the IANA registry lists ssh as 22/tcp. Telnet, which SSH replaced for most uses, is 23/tcp in the same registry.
A server admin can move sshd to another port. If a server does, add -p to the command:
ssh -p 2222 username@server-ipMoving the port only reduces noise from automated scans. It is not a security control by itself, so do not rely on it.
What is SSH vs Telnet?
Telnet (RFC 854, May 1983) lets you type commands on a remote machine, like SSH, but its base specification has no encryption layer at all. Anything you type, including a password, crosses the network as ordinary text. SSH was designed to fix exactly that.
| SSH | Telnet | |
|---|---|---|
| Default port | 22 (TCP) | 23 (TCP) |
| Encryption | Yes, always | None in the base protocol |
| Server identity check | Yes, host keys | No |
| Login methods | Password, public key, host-based | Username and password |
| File transfer | Built in through SFTP and SCP | No |
| Port forwarding | Yes | No |
| Standard | RFC 4251–4254 (January 2006) | RFC 854 (May 1983) |
| Use today | The normal choice | Rare; sometimes for testing whether a port is open on a trusted network |
What is SSH used for?
- Remote login. Open a shell on a Linux server, a Raspberry Pi, a router or a cloud instance.
- Running one command remotely. For example,
ssh username@server-ip uptimeruns one command and returns. - Secure file transfer.
scpandsftprun over SSH. The OpenSSH 10.6 notes begin deprecatingscp -R, the remote-to-remote copy flag. - Git over SSH. GitHub and similar services let you push and pull with an SSH key instead of a password or token.
- Tunnelling. SSH can forward a port from your computer to a remote network through the encrypted connection. A separate post on SSH tunneling is coming.
- Automation. Deployment and backup scripts use keys so that no human has to type a password.
How do I run the basic SSH command?
The pattern is the same everywhere:
ssh username@server-ipusername is the account on the server, and server-ip can also be a hostname. SSH never takes the password on the command line. It asks for it, or uses your key. Here is a real run against our practice server, where -p sets the port, -i picks the key, and -T skips opening a terminal (the server prints a message and exits):
ssh -T -i demo_key -p 2222 saurabh@127.0.0.1Warning: Permanently added '[127.0.0.1]:2222' (ED25519) to the list of known hosts.
Welcome to the demo server
user=saurabhThese are the options you will use most:
| Option | What it does | Example |
|---|---|---|
-p | Connect to a different port | ssh -p 2222 user@host |
-i | Choose which private key file to use | ssh -i ~/.ssh/id_ed25519 user@host |
-v | Verbose output; add more vs for more detail | ssh -v user@host |
-l | Give the username as an option | ssh -l user host |
-L | Forward a local port through the connection | ssh -L 8080:localhost:80 user@host |
-J | Jump through another server first | ssh -J jump@host1 user@host2 |
-o | Pass any config option for this run | ssh -o ConnectTimeout=5 user@host |
-N | Do not run a remote command (useful with -L) | ssh -N -L 8080:localhost:80 user@host |
On Windows 10 and 11 the same command works in PowerShell once the OpenSSH client is on. The client may already be installed. Run ssh -V to check. If it is missing, open Settings, find Optional features, add the OpenSSH Client feature, as Microsoft’s install guide describes. On a Mac, ssh is already in Terminal.
How do I create an SSH key with ssh-keygen?
A short section, because the full walk-through belongs in the next post. Ed25519 is the type GitHub’s documentation uses in its examples, and it is the sensible default today:
ssh-keygen -t ed25519 -C "demo@example.com"Real output (We used -N "" for an empty passphrase here only so the command could run unattended; on your own machine, set a passphrase when asked):
Generating public/private ed25519 key pair.
Your identification has been saved in ./demo_key
Your public key has been saved in ./demo_key.pub
The key fingerprint is:
SHA256:FY60YsAtnlfiH2QNd5Mi1qbvLP8X52co2zHY7/FX25w demo@example.com
The key's randomart image is:
+--[ED25519 256]--+
| ... o+o o. |
| o.o.*==o.. |
| . +o*o+o. |
| o.o.o. |
| . .So |
| . . o. o|
| o . +B=|
| . o ..oEX|
| o..o+.o*|
+----[SHA256]-----+Two files appear. The private key (demo_key) must stay secret and was created with permissions -rw-------. The public key (demo_key.pub) is safe to share, and it is one line:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILoj6ygGP4tPlDAWfAyagtN6Yij1r/AMF/RNpR+LQAzJ demo@example.comTo use the key, the public line goes into ~/.ssh/authorized_keys on the server. The usual helper is ssh-copy-id -i ~/.ssh/id_ed25519.pub username@server-ip. (not run here). For GitHub, you paste the public key into your account settings; GitHub supports Ed25519 and has not accepted DSA keys since 15 March 2022. See GitHub’s SSH guide. A deeper “SSH keys for GitHub” post is planned.
What are the common SSH errors and how do I fix them?
We reproduced these four on the test machine. The messages below are copied from real runs.
1. Connection refused. Nothing is listening on that port. The server may be off, sshd may not be running, or you used the wrong port.
ssh: connect to host 127.0.0.1 port 2222: Connection refusedFix: check the address and port, and that sshd is running on the server.
2. Permission denied (publickey). The server rejected your key. Usually the public key is not in the right authorized_keys file, or you offered a different key. We got this with a freshly made key that the server did not know:
saurabh@127.0.0.1: Permission denied (publickey).Fix: confirm which key you are offering with ssh -v, make sure the matching public key is in ~/.ssh/authorized_keys for that user, and check you are using the right username.
3. Host key changed. The key the server presents is not the one saved in known_hosts. This can be harmless, for example after a server rebuild, but it can also mean someone is intercepting the connection. Real output (trimmed):
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
The fingerprint for the ED25519 key sent by the remote host is
SHA256:Y1vUjAMpEB6+wQc7UNGOm0EhqlCdhAopY5iQl53xvtQ.
Offending ED25519 key in kh:1
remove with:
ssh-keygen -f 'kh' -R '[127.0.0.1]:2222'
Host key verification failed.Fix: first confirm with the server’s owner that the change is expected. Then remove the old entry with the ssh-keygen -R command it prints, and connect again.
4. Unprotected private key file. SSH refuses a private key that other users can read:
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
Permissions 0644 for 'bad_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "bad_key": bad permissionsFix: chmod 600 ~/.ssh/id_ed25519. On Windows, remove other users from the file’s permissions.
5. Connection timed out. The packets get no answer at all, which usually means a firewall or security group is blocking port 22, or the IP is wrong. The standard message looks like this: ssh: connect to host server-ip port 22: Connection timed out. (not reproduced on the test machine). Fix: check the firewall or cloud security group, and the IP address.
How do I keep SSH secure?
Strong encryption does not help if the login is weak or the server is out of date, so these habits matter most:
- Use keys, not passwords. Create an Ed25519 key and give it a passphrase. Use
ssh-agentso you type the passphrase once per session. - Turn off password login on servers once your key works. In
/etc/ssh/sshd_config, setPasswordAuthentication no. - Do not log in as root. Set
PermitRootLogin noand use a normal account withsudo. - Test before you log out. After editing, reload the service (for example
sudo systemctl reload sshon many Linux systems), and open a second terminal to confirm you can still get in before closing the first. - Add
fail2ban. It watches logs and temporarily blocks addresses that keep failing logins. It is a common, free layer on top of the settings above. - Keep OpenSSH updated. The 10.6p2 release notes include a security fix. Install your distribution’s updates.
- Check host key fingerprints the first time you connect, and never ignore a “host key changed” warning.
- Read the post-quantum warning. If you see it, update the server.
The same habits protect a website host. The WordPress security checklist covers the SFTP and hosting side.
SSH FAQ
What is the full form of SSH?
Secure Shell. The standard name is the Secure Shell (SSH) Protocol.
What port does SSH use?
TCP port 22 by default. An admin can change it, and then you connect with ssh -p PORT user@host.
Is SSH secure?
Yes, when it is used correctly: current OpenSSH versions use strong encryption and check the server’s identity. The weak points are usually weak passwords, stolen private keys, ignored host key warnings and unpatched servers.
What is the difference between SSH and Telnet?
Both give you a remote command line. Telnet sends everything in plain text on port 23. SSH encrypts everything and verifies the server, on port 22.
Is SSH TCP or UDP?
TCP. The SSH connection runs over a TCP connection, which is why the port is listed as 22/tcp.
Which key type should I use?
Ed25519, unless a very old system forces you to use RSA. DSA is gone from OpenSSH 10.0 onward.
What should I read next?
The next post in this series is how to SSH into a server, a step-by-step guide covering Linux, Mac and Windows 11. Coming soon (no link yet). After that: SSH tunneling, the ~/.ssh/config file, and SSH keys for GitHub. Until then, if you run a website, read the WordPress security checklist.
Questions about an SSH error or a setup? Leave a comment with the exact message you see and your operating system, and we will help.
Sources
- RFC 4251: The Secure Shell (SSH) Protocol Architecture (January 2006)
- RFC 4252: SSH Authentication Protocol
- RFC 4253: SSH Transport Layer Protocol
- RFC 4254: SSH Connection Protocol
- RFC 854: Telnet Protocol Specification (May 1983)
- RFC 8709: Ed25519 and Ed448 public key algorithms for SSH
- OpenSSH release notes and OpenSSH post-quantum cryptography
- OpenSSH ssh manual
- IANA service name and port number registry
- Microsoft Learn: OpenSSH for Windows overview and Get started with OpenSSH
- GitHub Docs: Connecting to GitHub with SSH




