Knowledge centre

Harden access in the right order

Strengthen a real server's administrative login while keeping a verified way back in.

2 min readEnglish

Content revised · English

At a glance
Guide type
Operate & secure
Examples
Illustrative, environment-specific
Integration scope
No remote machine connected
01

Create a tested non-root administration path

First establish a named account with the permissions you need, install its public key and confirm key login plus sudo in a second session. Keep the current session open. Direct root access should be disabled only after the replacement route works.

02

Change the authentication rules deliberately

Review the active sshd_config and included snippets; the first applicable value can win. The following is a key-only example. If a legitimate PAM or MFA design uses keyboard-interactive authentication, adjust that line for the design rather than disabling it blindly.

Prepared key-only policy · review includes firstReview for your environment
PubkeyAuthentication yes
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
AllowUsers operator
03

Validate syntax and reload the right unit

Check the configuration before applying it. On Ubuntu the service is commonly named ssh; other distributions may use sshd. Reload only the unit that exists, then open another key-authenticated session. Keep a verified console route available.

Ubuntu example after validationReview for your environment
sudo /usr/sbin/sshd -t
sudo systemctl reload ssh
ssh -i ~/.ssh/ombra_admin operator@192.0.2.20
04

If changing the port, open the new path first

A different port reduces some automated noise, but is not authentication. Before configuring port 22222, permit it in the guest and upstream firewalls. Socket-activated SSH can require a distribution-specific socket update. Verify the new listening address and a second connection before retiring port 22.

Order of checks · not a complete port-change scriptReview for your environment
sudo ufw allow 22222/tcp
sudo ss -lntp
ssh -p 22222 -i ~/.ssh/ombra_admin operator@192.0.2.20
05

Keep protection and recovery measurable

Limit source addresses where practical, review login events and maintain updates. Fail2ban can reduce repeated attempts when the correct log backend is configured. Check IPv6 as well as IPv4. Save the effective policy and console recovery procedure before closing the original session.

BEFORE THE NEXT STEP

Leave with a verifiable result.

  • Create a tested non-root administration path.
  • Keep protection and recovery measurable.
  • Keep recovery information and secrets outside public files.
GO TO THE PRIMARY SOURCEOpenSSH · server policyUbuntu · OpenSSH deployment