SSH fundamentals

How an SSH connection works

SSH creates an encrypted channel between your device and a remote system. During SSH authentication, the server verifies the user or workload requesting access. Security depends on more than encryption: you must identify the server, protect your credentials, and use the access you were actually granted.

9 min readIndependent guidance
In this guide
The four stages of an SSH connectionConnect with a command-line SSH clientVerify the host before authenticatingTroubleshoot by layerClose the session cleanlyFrequently asked questions
01

The four stages of an SSH connection

Network connection

The SSH client reaches a host and TCP port, commonly port 22.

Server identification

The server presents a host key. Your client checks it against a known or trusted fingerprint.

Encrypted session

Client and server negotiate algorithms and create protected session keys.

User authentication

The server verifies your account using an approved method such as a public key, password, or hardware-backed credential.

02

Connect with a command-line SSH client

A typical OpenSSH command identifies the username and destination. Add a nonstandard port only when your administrator specifies one.

Standard port

Connect as the named account.

ssh [email protected]

Custom port

Use the server’s documented port.

ssh -p 2222 [email protected]

Examples are placeholders. Do not probe systems or attempt access without authorization.

03

Verify the host before authenticating

On a new connection, compare the SHA-256 host key fingerprint with a value obtained from an administrator, inventory, or another trusted channel. A matching hostname alone is not enough.

If a previously known host key changes, stop and investigate. Legitimate causes include a server rebuild or key rotation, but the same warning can indicate redirection or interception.

04

Troubleshoot by layer

  • Timeout: check hostname, network route, VPN requirement, firewall, and port.
  • Connection refused: verify the port and whether the SSH service is running.
  • Host key warning: do not remove the old key until the change is independently verified.
  • Permission denied: verify username, authorized key, key selection, and account policy.
  • Session closes: review server policy, shell access, and permitted commands with the system owner.
05

Close the session cleanly

Exit the remote shell, confirm that local forwarding has stopped, and close the client. For shared or managed workstations, follow the organization’s rules for clearing agents, temporary files, and session logs.

Common questions

Frequently asked questions

Is SSH always on port 22?

Port 22 is the default, but administrators can use another port. A different port reduces background noise; it does not replace authentication and access controls.

Why does SSH ask about a fingerprint?

The fingerprint represents the server host key. Verifying it helps detect a connection to the wrong or impersonated server.

Can I use SSH without PuTTY?

Yes. Windows includes an OpenSSH client on many systems, and other platforms commonly provide one. PuTTY is one option among several.