From root password to key-only administrator: initial access through CLI

A fresh Debian VM, new administrator, password-required sudo and SSH policy: the actual CLI run, refusals and verification after disabling root login.

A large key beside a shielded entrance, with a separate terminal at the side.
A large key beside a shielded entrance, with a separate terminal at the side.

Initial access has several steps: log in as root, create a separate administrator, verify their key and sudo, then restrict SSH. I connected these actions in a separate host setup scope. On a fresh Debian VM it went from a root password to a verified administrator and disabled root/password login. This is a distinct step before PHP, Symfony and HTTPS setup.

Prerequisites before the run

The VM already has Debian, Python3, OpenSSH and sudo. Host-key trust was checked independently, and console evidence identifies the machine and current boot. This run verifies access setup after those prerequisites. Firewall, WireGuard, databases and installing missing base packages have their own stages.

Two channels for one specific server

The initial root profile and future administrator profile name the same host, port and trusted SSH host-key file. The root password stays in a separate private file. The administrator request references their public key, verification identity, OS password for sudo and console evidence. The JSON profile contains no secrets; these paths are placeholders:

{
  "schema_version": 1,
  "entry_mode": "clean",
  "environment_file": "/private/example-administrator.env",
  "access_bootstrap": {
    "root_environment_file": "/private/example-root.env",
    "request_file": "/private/example-access-request.json"
  }
}

Operator files are private, and the control directory has mode 0700. Hostname-only console evidence is insufficient: the machine and boot are checked in the same SSH execution before the command. Unknown host-key trust is never accepted automatically.

Plan a new administrator first

Planning requires the selected account and original paths to be absent. It retains the original administrator command’s exact plan and binds it to the inputs and executable CLI. An existing user with the same name does not authorize changing that account.

deploy-cli host setup plan \
  --profile-file "$ACCESS_PROFILE" --plan-file "$ACCESS_PLAN"

Create and verify before restricting SSH

After reviewing the plan, separately approve operator-local records and privileged VM actions. The password is not a command argument. First, the original module creates the administrator, installs the selected key and configures sudo. It then opens a fresh connection using that key and verifies that sudo really requires a password.

deploy-cli host setup apply \
  --plan-file "$ACCESS_PLAN" --plan-sha256 "$ACCESS_PLAN_SHA256" \
  --approve-local-write --approve-privileges

Only then is SSH policy planned. Its original command retains a recovery connection, validates configuration, reloads the service and verifies administrator access again. Additional probes confirm root denial and publickey-only authentication. Selected actual CLI JSON response fields follow:

{
  "status": "passed",
  "scope": "root-bootstrap-to-key-only-administrator",
  "completed_stages": 2,
  "host_write_attempted": true,
  "host_write_performed": true,
  "access_ready": true,
  "runtime_ready": false,
  "whole_host_ready": false
}

Final verification uses the administrator

The completion has an independent SHA256 and binds ten operator-local control files: plans, intents and actual results. After root login is disabled, final verification uses the administrator channel to check retained files and current access:

deploy-cli host setup verify \
  --plan-file "$ACCESS_PLAN" --plan-sha256 "$ACCESS_PLAN_SHA256" \
  --completion-sha256 "$ACCESS_COMPLETION_SHA256"
{
  "status": "passed",
  "completed_stages": 2,
  "local_write_attempted": false,
  "host_write_attempted": false,
  "access_ready": true,
  "runtime_ready": false,
  "whole_host_ready": false
}

I separately read the effective SSH configuration. Selected actual lines from the standard command’s full output follow:

sudo /usr/sbin/sshd -T
permitrootlogin no
pubkeyauthentication yes
passwordauthentication no
kbdinteractiveauthentication no
authenticationmethods publickey

Service state was also read separately. This is the command’s actual stdout, without an additional restart:

systemctl is-active ssh.service
active

What happens on refusal

A plan with a different boot refused before account changes, preserving the selected VM state. Apply replay without a completion digest and verify with an incorrect digest also refused. During reads, all 12 selected files and service observations stayed exact.

The first separate fixture had created and verified its administrator, but the coordinator required a SHA field that the original access response does not contain. It stopped before SSH policy. The correction changed response admission while retaining exact local binding to the reviewed plan. That partial run was not resumed; the successful run used another fresh VM. After a dense sequence of negative authentication checks, immediate repeat reading received a temporary SSH refusal. Independent console diagnostics showed penalty: failed authentication. A later administrator login and repeat reading passed, without weakening SSH protection or rerunning installation. Separate model tests cover a lost acknowledgement after a write; they do not claim a real VM interruption.

The frame below is a genuine terminal summary of saved results. Server commands were not executed again during capture.

Fresh VM proof covers root password, new administrator, sudo and SSH restrictions
A genuine VTE frame summarizing saved results. A fresh VM completed administrator creation and SSH policy after separate console and base-prerequisite checks. SSH temporarily refused immediate replay; later reading passed without writes. Commands were not executed again during capture.

What is ready after this step

access_ready=true covers administrator admission and SSH policy within the accepted boot. runtime_ready and whole_host_ready remain false. Independent firewall acceptance, WireGuard and selected services still need to join the verified runtime coordinator. Interactive credential collection is another step; this version reads explicitly prepared private profiles.

  1. Operations & Security A separate administrator: from key login to the right privileges
  2. Operations & Security When to restrict root and password-based SSH
  3. Operations & Security Recovering VPS access when SSH stops working
  4. Operations & Security Planned SSH key rotation: verifying new access and revoking the old key
  5. Operations & Security Firewall acceptance through CLI: provisional rules and independent approval

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article