top of page

What is SSH Session?

Oct 25
10 min read

Updated: Oct 27

Command-line client communicating with a remote server through a protected SSH session.

 

An SSH Session is a period of remote work carried over Secure Shell, commonly an interactive command-line login to another computer. Your SSH client sends input through a protected connection, the remote system runs the authorised program, and its output returns to your terminal.

 

There is also a more precise protocol meaning. SSH can carry several logical channels, and a session channel requests a remote shell, command or subsystem. The network connection, the session channel, the terminal window and the running process are related objects, but they are not the same thing.

 

That distinction matters when a login fails, a command appears to freeze or a connection drops during important work. Establishing an encrypted path does not automatically grant every permission, and reconnecting does not automatically reconstruct the previous working environment.

 

Separate the connection from the work it carries

 

Think of an analyst connecting from a laptop at home to an organisation's approved log server. The laptop provides the client interface. The remote account and server determine what the analyst can run and read.

 

Object

Its role in the example

SSH connection

The protected communication relationship between the SSH endpoints.

Logical channel

A distinct stream carried within that connection. Several channels can share it.

Session channel

A channel used to start a remote shell, command or named subsystem.

Pseudo-terminal, or PTY

A terminal-like interface allocated for a remote program when needed.

Remote process

The actual shell, command or application running on the destination system.

Local terminal window

The interface displaying the interaction on the analyst's laptop. Closing it is not a universal description of every remote process's outcome.

 

The IETF's SSH Connection Protocol, RFC 4254, defines session channels and the requests that start a shell, command or subsystem. A session can operate without a pseudo-terminal. Within one session channel, those program-start requests are alternatives; separate channels can support separate work.

 

This is why “I opened three SSH sessions” needs context. It might mean three independent network connections, or several sessions sharing a connection through an implementation's connection-sharing feature. Those arrangements have different setup costs and failure boundaries.

 

Follow one login from the laptop to the remote program

 

The SSH version 2 architecture separates transport protection, user authentication and the channels used for work. The familiar command prompt appears only after the relevant preceding stages have succeeded.

 

  1. The client finds and reaches the intended SSH service through the approved network path.

  2. The peers exchange protocol identification and negotiate the supported protection mechanisms.

  3. The client establishes trust in the server's identity through its host key and the organisation's supported verification method.

  4. The server authenticates the requested user using the permitted method or combination of methods.

  5. The client requests an allowed channel and, for suitable interactive work, a pseudo-terminal and shell.

  6. Input reaches the remote program, and its output returns through the channel to the client interface.

 

In the usual TCP deployment, the server listens on port 22 unless configured otherwise. The port identifies a service endpoint; using that port does not itself establish that the server is genuine or the user is authorised.

 

The initial protocol identification is not the same as encrypted application traffic. SSH negotiates its protection during setup. Supported, maintained software and appropriate configuration remain necessary; a protocol name alone is not a guarantee about every implementation or algorithm selection.

 

The early SSH architecture and transport RFCs date from January 2006. Later specifications update parts of their cryptographic guidance, including RFC 9142's key-exchange recommendations. Treat the original documents as the foundation for the mechanism, not as a list of algorithms to enable today.

 

The infographic shows the identity checks and a conceptual channel arrangement. Its separate shell, command and file lanes represent different logical channels, not three program-start requests succeeding inside one session channel.

 

What is SSH Session infographic explaining the mechanism, key stages and practical limits.

 

The server's host key and your user key answer different questions

 

Before trusting a login prompt, the client needs confidence that it has reached the intended server. The server then needs evidence that the requester may use a particular account. These checks face in opposite directions.

 

Check

Question it answers

Server host identity

Is this the server the client intended to contact?

User authentication

Has the requester supplied acceptable evidence for this remote account?

Authorisation

What may that authenticated account actually do?

 

A host-key fingerprint is a representation used to help identify the server's public key. Verify an unfamiliar or changed key through the administrator's trusted process. A server rebuild or planned rotation can explain a change, but the warning alone does not prove that a change is legitimate.

 

Do not simply disable host checking or delete a remembered key to make the warning disappear. Establish the expected identity first. Encryption to the wrong endpoint does not solve the identity problem.

 

Public-key user authentication works differently: the client creates a signature using the relevant private key, and the server verifies it against an acceptable public key. The private key is not sent as the authentication proof. The server can require additional authentication as part of its policy.

 

A private-key passphrase protects use of that private key; it is not necessarily the remote account password. Protect private keys and their supporting devices, and use the organisation's approved authentication arrangement rather than assuming that any key file grants access everywhere.

 

Where does an SSH command run?

 

The OpenSSH client manual describes destinations in the form user@hostname and the option to execute a remote command instead of starting a login shell. For illustration, ssh analyst@server.example requests access to the account analyst at a placeholder server name. It is not an instruction to contact a real system.

 

Once a remote shell is established, commands entered at that remote prompt run in the remote account's environment. The current directory, available tools, file permissions and resource limits belong to that environment. The laptop is displaying the interaction rather than doing all the remote computation itself.

 

This creates an easy operational mistake: confusing a local terminal with a remote one. Before changing files or starting work, confirm the destination and account using the environment's normal checks. A familiar prompt colour or window title is not a strong substitute for knowing where the command will execute.

 

An automated command can use input and output streams without a terminal-like interface. An interactive full-screen program may need terminal facilities such as screen size and terminal modes. Adding a PTY is therefore a behavioural choice, not a general repair for every failed command.

 

A successful login also does not imply administrative privilege. A command can fail because the account lacks permission, a file is absent, a program is unavailable or a server-side restriction intentionally denies that action. Diagnose that result at the appropriate layer.

 

Several channels can share one protected connection

 

Channel identifiers keep streams logically distinct, and channel flow control limits how much data a peer may send before receiving further allowance. This sits inside the connection rather than replacing the network's own transport behaviour.

 

As a conceptual example, one approved connection could carry a terminal interaction, a separate command and a file-transfer subsystem. Each has its own purpose, while all depend on their shared connection. A single channel ending need not mean that every other channel has ended.

 

OpenSSH's ControlMaster facility can let additional client sessions reuse an existing connection through a local control socket. Ubuntu's server documentation also describes connection multiplexing as a way to reduce repeated setup. This is connection reuse, not independent connectivity for every session.

 

The trade-off is a shared dependency. If the underlying connection fails, the channels carried over it lose that path together. The local control socket also belongs in the operator's access-control design; connection sharing should be configured through the supported documentation for the installed software.

 

Rekeying is another separate operation. SSH can replace its traffic-protection keys during an existing connection. That does not inherently start a new remote shell or require a fresh user login. It should not be confused with reconnecting after the transport has been lost.

 

Why a fast broadband line can still feel slow

 

Typing and reading a small amount of text often require little sustained data capacity. Responsiveness can still suffer when the path has substantial delay, packet loss or competing traffic, or when the remote host is busy.

 

Consider an invented operation that needs eight strictly sequential network round trips before it finishes. Assume the same processing and rendering work in both cases and ignore connection setup. The network-wait contribution is eight times the round-trip time.

 

Assumed round-trip time

Network waiting for eight sequential exchanges

25 ms

8 × 25 ms = 200 ms.

100 ms

8 × 100 ms = 800 ms.

Difference

600 ms of additional waiting in this simplified example.

 

This is an explanatory model, not a measurement of SSH or a claim that every keystroke needs eight round trips. Real applications may batch, overlap or locally render some activity. The model simply shows why more download capacity does not remove a distant round trip.

 

Bulk output and file transfer have different demands. A command producing a large result can consume substantial capacity. If that traffic competes with an interactive channel on a shared path, the experience may change even though the terminal itself sends little input.

 

For a UK home worker, useful checks include the local Wi-Fi path, traffic sharing the broadband line, the route to the remote service and the remote system's load. The headline download rate is only one part of that end-to-end arrangement.

 

Keep-alive, inactivity policy and recovery are separate jobs

 

A quiet terminal may be healthy, waiting for input or waiting for a long-running operation. It may also have lost its usable path without the client immediately displaying an error. Silence alone does not identify the state.

 

OpenSSH provides server-alive messages through the protected SSH channel to help detect an unresponsive peer. These differ from TCP keep-alive probes. They do not restore a failed connection, recreate a shell or prove that a remote business operation completed.

 

The server can also apply an inactivity policy to a channel. Current OpenSSH documentation distinguishes channel expiry from closing the entire connection and warns that associated processes may remain. Consult the installed version and effective policy rather than assuming that one timeout removes all remote resources.

 

The Session Timeout article explains why a lifetime rule, a connection failure and a request timeout need separate investigation. An approved server policy is not something to bypass by manufacturing activity.

 

OpenSSH's online manuals describe its latest development release. Features, defaults and configuration details may differ in a packaged client or server. This article explains the roles of those facilities rather than prescribing settings for an unseen system.

 

Does work survive when the SSH connection drops?

 

There is no universal answer for every process and environment. The remote program's relationship to its terminal, the operating system, service policies and any job or session manager all affect its lifetime.

 

A terminal multiplexer provides one useful arrangement. The official tmux manual describes sessions managed by a separate server process that can remain available after detaching or losing a client connection. A later client can attach to that retained terminal environment.

 

This preserves a different object from the SSH connection. A fresh SSH login can provide a route back to an existing tmux environment if it is still running and accessible. It does not revive the old transport or guarantee survival after a server reboot, process termination or administrative cleanup.

 

For important long-running work, establish the supported persistence mechanism before starting. Depending on the environment, that may be a terminal multiplexer, a managed service or a job system. A command already launched in an ordinary session cannot be assumed to acquire persistence merely because a connection has failed.

 

A lost reply creates another issue. Suppose the analyst submitted an action, then lost the connection before seeing the result. The action may have completed, failed or remained in progress. After reconnecting, inspect the actual task state or records before issuing the same action again.

 

That recovery sequence protects against duplicate work as well as lost work. Restoring connectivity, finding the retained environment and determining the operation's outcome are three separate checks.

 

Diagnose the last stage that succeeded

 

A useful report states the destination, time, exact message and last successful stage. “SSH is broken” does not distinguish a name-resolution failure from a rejected user key or an unavailable shell.

 

Symptom

Useful distinction

Destination name cannot be resolved

Check the approved name and relevant DNS or client configuration.

Connection is refused or times out before login

Check service availability, the intended port and the permitted network path.

Host-key warning appears

Establish the expected server identity through a trusted route before proceeding.

Authentication is rejected

Check the account, permitted authentication method and intended credential with the administrator.

Authentication succeeds but shell or subsystem fails

Check channel permissions, the requested program and server-side restrictions.

Prompt appears but one command fails

Investigate that command's environment, input and permissions.

Terminal stops responding or connection drops

Separate remote processing, network failure, client detection and inactivity policy.

Result is unknown after disconnection

Inspect the remote operation before retrying it.

 

OpenSSH's verbose mode, selected with -v, can show progress through connection and authentication stages. Use it on an authorised destination when appropriate, and review the output for private hostnames, account information and other sensitive details before sharing it.

 

Avoid changing several configuration settings at once. If the failure is a correct account restriction, opening a network path will not grant permission. If the service is unreachable, repeatedly replacing a valid user key will not make it reachable.

 

Keep the access boundary understandable

 

SSH protects communication within its defined endpoint relationship. It does not make a compromised client or server trustworthy, and it does not prevent an over-privileged account from doing damaging work.

 

Forwarding adds further relationships. A forwarded application can have its own identity, encryption and permission requirements beyond the SSH endpoint. The SSH link does not automatically prove that every later segment is protected or that every destination is authorised.

 

Agent forwarding also deserves care. OpenSSH warns that a compromised remote environment can use a forwarded agent to perform authentication operations with available identities, even without extracting the private key material. Enable additional facilities only when the approved task and trust arrangement require them.

 

The Remote Access article places these questions in the wider context of reachable services, identity checks and permitted actions. For SSH, keep the same discipline: verify the destination, authenticate appropriately, use the account's intended scope and understand recovery before relying on the connection for important work.

 

Frequently asked questions

 

Is an SSH session the same as a remote desktop?

 

No. A common SSH session carries command-line input and output. A remote desktop provides a graphical desktop interaction. SSH can support other channels and forwarding, so its uses extend beyond a simple shell.

 

Does the private key get sent to the server?

 

In public-key user authentication, the client sends a signature that the server can verify. It does not send the private key as the proof.

 

Can one SSH connection carry several sessions?

 

Yes, the protocol supports multiple logical channels. Whether separate client invocations share a connection depends on the implementation and configuration.

 

Will a keep-alive preserve my remote job?

 

It is not a job-persistence guarantee. Determine how the remote task is managed and what happens when its terminal or connection ends.

 

Does reconnecting restore my previous shell?

 

Not automatically. A new connection can reach a retained environment when an appropriate persistence mechanism is already in place, but ordinary reconnection does not reconstruct every previous process and state.

 

Key takeaway

 

An SSH Session combines a protected path with authenticated, authorised remote work. Keep the server identity, user identity, connection, channel and remote process distinct. That makes setup easier to understand, failures easier to locate and recovery less likely to lose or duplicate important work.

 
 
UK Techie Broadband Providers
bottom of page