Join our Newsletter — 33% off our NHI Course
Home› Glossary› Governance, Ownership & Risk› SSH Command Restrictions
Governance, Ownership & Risk

SSH Command Restrictions

← Back to Glossary
By NHI Mgmt Group Updated October 28, 2026 Domain: Governance, Ownership & Risk

SSH command restrictions are controls that limit which commands a user or key may run when opening an SSH session. They are typically enforced through forced commands, restricted shells, or authorised_keys options, so a stolen SSH key cannot automatically grant full interactive access or arbitrary command execution.

How SSH Command Restrictions Work

SSH command restrictions narrow what happens after authentication succeeds. Instead of granting a full shell, the server or key policy can force a single program, wrap the session in a restricted shell, or constrain what an ssh key may execute through authorized_keys options.

That design matters because SSH access is often treated as equivalent to trust. Command restriction breaks that assumption by separating “can log in” from “can run anything”, which is especially useful for automation, jump hosts, and delegated operational access.

Where They Are Enforced

Restrictions can be applied at several layers, and the layer matters. A forced command in authorized_keys is tied to a specific key, while a restricted shell applies to the account itself, and server-side policy can add another boundary after authentication. The same session may therefore be limited by more than one control.

Because these controls live at the session boundary, they are only as strong as the surrounding SSH configuration. If the account can still invoke an unrestricted shell through another path, or if the key is reused elsewhere, the restriction becomes partial rather than absolute. For that reason, SSH command restrictions are usually paired with careful SSH key management.

What They Protect Against

The main security value is containment. If an SSH key is stolen, copied, or mistakenly shared, the attacker should not automatically gain an interactive administrative foothold. Instead, the session can be limited to a backup job, file transfer action, build step, or other narrowly defined task.

They also reduce damage from legitimate-but-overpowered access. Many operational keys are issued for convenience and later become persistent privileges. Restricting commands limits lateral movement, prevents ad hoc exploration, and reduces the chance that a routine automation account becomes a general-purpose entry point.

Why They Need Careful Design

SSH command restrictions are security controls, not a complete trust model. If the forced command launches a script, the script becomes part of the attack surface. If the shell remains too flexible, the user may still escape into other programs, chain commands, or abuse environmental variables and file permissions.

The control is strongest when the allowed action is tightly scoped, the account owns no unnecessary privileges, and the surrounding host hardening supports the restriction. That is why the same pattern can be excellent for a single-purpose deployment key and weak for a broadly shared administrator account.

Risk and Threat Considerations

Command restrictions matter because a stolen SSH key often remains usable long after the original compromise. Without a forced-command boundary, that key can become an easy path to full shell access, privilege escalation, or automation abuse. With weak restriction design, the attacker may still pivot through the permitted command into broader execution.

Failure mechanism: The restriction fails when the allowed command is too powerful, the wrapper script is bypassable, or the key is reused in a context that permits broader execution than intended.

Impact: A compromise that should have been contained to one task can turn into unauthorized command execution, persistence, data access, or service disruption.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5 and CIS Controls v8 set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementSSH command restrictions depend on controlling how keys are issued and used.
AC-6 — Least PrivilegeRestricting commands is a least-privilege measure for SSH sessions.
SC-7 — Boundary ProtectionForced-command and restricted-shell patterns enforce a boundary around session behavior.
Recommendation — Manage SSH keys tightly so restricted access cannot outlive its intended purpose. Limit SSH sessions to the minimum command set needed for the role. Constrain SSH session behavior at the boundary before broader access is exposed.
CIS Controls v8CIS-6 — Access Control ManagementSSH command restrictions reduce excess access by constraining permitted actions.
Recommendation — Apply access control management to remove broad SSH execution rights.
ISO/IEC 27001:2022A.5.15 — Access controlSSH command restrictions are an access control mechanism governing permitted operations.
Recommendation — Define and enforce SSH access rules that limit what authenticated users can execute.

Practitioner Guidance

Why practitioners should care: Treat SSH command restrictions as a privilege boundary, not just a convenience feature. They are most effective when a key or account exists for one operational purpose and should never be allowed to drift into general login access.

Governance implication: Define ownership for every restricted key, review whether the allowed command still matches the business purpose, and remove orphaned or duplicated access paths when the use case changes.

Practitioner takeaway: If the session can do more than the intended task, the restriction is not strong enough to be relied on as a control.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 28, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org