Course outline

Linux Security / Intermediate: service, policy, and lifecycle boundaries / Lesson 12

Review SSH and remote-access policy as a lifecycle

Separate server identity, user authentication, session authority, configuration precedence, and recovery.

About 4 min readContent reviewed
On this page

Lesson goals

  • Explain why public-key authentication is not a complete authorization or host-trust decision.
  • Review illustrative sshd settings without applying or testing them on a host.

Separate connection trust from session authority

SSH involves authenticating the server, authenticating the user, selecting an account/session, and constraining what that session may do. A successful key check does not prove the remote host is the intended one or that every requested action is authorized. Host-key trust, user key lifecycle, account policy, forwarding, command restrictions, and recovery need distinct review. The selected configuration reference is Ubuntu 24.04’s OpenSSH documentation, not this host’s state. No connection, key generation, credential use, account inspection, or daemon operation is performed in the course.

Read a purpose-specific illustrative fragment

The fragment expresses one fictional policy: no direct root login, public-key-only authentication under the shown methods, and one invented allowed account. It is not a complete sshd configuration or a universal recommendation. A real change requires supported integration, credential enrollment, legitimate access, automation, and recovery assumptions. Include files and Match conditions can change the effective context; for many sshd keywords the first obtained value matters unless documented otherwise. Do not treat appending a line as proof it takes effect. No syntax check, reload, restart, login, or policy change is run here.

text An incomplete non-runnable SSH policy fragment
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
AuthenticationMethods publickey
AllowUsers admin-lab

The fragment is displayed as editorial text only and is never installed or parsed by sshd. The account is fictional. It does not enroll keys, preserve a real recovery route, verify host identity, or prove the effective authentication policy.

Keep authentication and account authorization separate

The local model requires declared server trust, successful user authentication, and an approved session action. It demonstrates that one true credential fact is insufficient. These booleans are synthetic trusted inputs; the program verifies no SSH exchange. A real client must obtain host trust through its approved mechanism rather than accepting a caller-supplied verified flag, and a server must enforce account and session policy through the actual supported stack. Preserve lifecycle changes such as revoked keys, disabled accounts, and existing sessions as separate questions rather than assuming one configuration line terminates all authority immediately.

python Check four declared remote-session policy cases
def session_allowed(server_trusted, user_authenticated, action_permitted):
    return server_trusted is True and user_authenticated is True and action_permitted is True

assert session_allowed(True, True, True) is True
assert session_allowed(False, True, True) is False
assert session_allowed(True, True, False) is False
assert session_allowed(True, False, True) is False
print("server trust, authentication, and action policy remain distinct")
Expected output
server trust, authentication, and action policy remain distinct

The complete program evaluates in-memory facts only. It makes no SSH connection and uses no key, password, token, host record, or account. It establishes the fictional conjunction rather than actual authentication or authorization.

Review forwarding and command capabilities deliberately

A session can carry authority beyond a shell, including forwarding, agent use, file transfer, and delegated commands. Restrict capabilities according to the actual role rather than assuming public-key-only means limited use. Review environment acceptance, command arguments, account-owned files, and the lifecycle of any automation credential. Do not paste real authorized-key material into a course example or invent a homegrown key validator. The course creates no secret and configures no access. A narrow remote role should have explicit allowed tasks and denied alternatives, with recovery reviewed before any actual operational change.

Verify effective policy only in an authorized test environment

An approved disposable plan should cover intended client methods, host identity, allowed and denied accounts/actions, configuration precedence, and recovery. Record actual server/package versions and the source of each observation. No such daemon or identity operation runs here. A reviewed fragment is evidence of intent, while a successful local boolean model verifies only its policy relation. Preserve missing integration evidence and avoid claiming universal secure SSH from a few lines. The goal is a clear boundary and lifecycle decision that a real operator can review with concrete authorized evidence.

Common errors and fixes

A valid user key proves the server is intended

Why it happens
User authentication and host trust are confused.
How to fix it
Review host identity through the approved client trust mechanism.
Prevent it next time
Test the separate trust and authentication claims.

Appending a setting proves effective policy

Why it happens
Include order and conditional context are ignored.
How to fix it
Review the full selected configuration semantics and actual effective context.
Prevent it next time
Separate text review from daemon behavior.

Public-key-only is called least privilege

Why it happens
Session capabilities and action policy are omitted.
How to fix it
Define forwarding, command, account, and lifecycle scope.
Prevent it next time
Pair legitimate tasks with denied alternatives.

Check your understanding

1. The user is authenticated but server_trusted is false. What does the model decide?

Show worked solution

It refuses under the declared policy. Successful credential use cannot substitute for trust in the intended server. The calculation performs no protocol exchange, so actual client host verification and recovery remain separate authorized integration questions.

2. Why should a remote-access change include a recovery plan?

Show worked solution

A policy can correctly reject the only currently usable method or unintentionally affect automation and administration. Review supported enrollment, intended access, and an approved recovery path before any real change. This lesson applies nothing and does not test or preserve access to this host.

Key takeaways

  • Host identity, user authentication, and action permission differ.
  • Configuration precedence and session capabilities matter.
  • A fragment and local model do not establish effective SSH security.

Official references