--- name: server-initialize description: Выполняет первичную настройку сервера с обновлением системных пакетов или меняет учётные данные и правила доступа по SSH. --- Use the [server-ops checkout](../server-ops/SKILL.md#select-the-checkout) for all repository paths and commands in this skill. ## Before changes Resolve the endpoint, account, and host pin using [server operation](../server-operate/SKILL.md). Confirm OS, package manager, and administrative privileges. For SSH changes, retain the working session and a recovery route. Back up the actual SSH configuration outside its include paths before editing it. ## Package updates during initialization A requested initial setup includes refreshing package indexes and upgrading installed packages. This includes password-to-key setup on a new server. For Debian or Ubuntu run `apt-get update` followed by `apt-get upgrade`. Use the supported procedure on other distributions. Inspect errors and held packages. Record completion, pending packages, and required reboots. Keep package removals, release upgrades, and reboots inside explicit scope. For an SSH-only change on an established server, apply the requested access change. Pause a combined cutover if an upgrade failure leaves access or package state uncertain. [APT update and upgrade](https://manpages.debian.org/bookworm/apt/apt-get.8.en.html) ## Change a key or SSH policy 1. Use the requested public key or derive it from the selected local private key. When asked to make a new key, generate the pair in a private temporary directory. Install the public key for the requested account. Preserve the other authorized keys, ownership, and permissions. 2. Prove a fresh login with the exact candidate key, existing pin, and expected privileges. On Linux use `python3 .agents/scripts/ops.py ssh --probe-key PATH ALIAS -- id -un`. Use `--connection NAME` for a specific endpoint. A `.pub` path selects the matching key in `ssh-agent`. Load a passphrase-protected key into the agent for the non-interactive probe. A private-file probe requires a key that opens without a prompt. Use the PowerShell runner in the operation skill when working on native Windows. 3. Use the [credential commands](../server-onboard/SKILL.md#credentials) to store the private key and verify it with `check-secret ALIAS` before restricting access. Keep the existing working credentials available while testing the stored key with a fresh login and privilege check after package upgrades. Proceed with an external key only if the operator chose it. 4. Apply the requested SSH policy within scope. Before a server-wide cutover, verify access for the accounts that must retain it. Validate the running daemon's config and arguments with `sshd -t` and `sshd -T -C ...`, including real endpoint/user parameters and applicable `Include` and `Match` rules. For key-only access, verify `PubkeyAuthentication yes`, `AuthenticationMethods publickey`, `PasswordAuthentication no`, and `KbdInteractiveAuthentication no`. Reload via the supported service mechanism. [OpenSSH daemon checks](https://man.openbsd.org/sshd.8) · [SSH policy options](https://man.openbsd.org/sshd_config.5) 5. Verify a fresh pinned login and privileges after reload. On a failed cutover use the retained session or recovery route to restore, validate, reload, and verify the prior configuration. Record the observed partial state or recovery result. ## Change a password Use the platform's account management tool and a protected input channel. Retain recovery access and keep the current SOPS entry until the new credential is verified. Confirm a fresh password login when SSH password access is part of the requested policy. For other password uses, verify with a check appropriate to that use. Store the verified new credential through the SOPS workflow. ## Update the record Update the selected profile or legacy account's `auth`. With a mapped `auth`, set method status from observed results and change `auth.default` when switching the intended default. Use `encrypted_key` for keys stored as SOPS ciphertext in the card. Preserve operator-selected external key or agent references and existing legacy SOPS records when applicable. Before recording server-wide `ssh_policy: key_only`, reconcile all password methods with verified policy. Keep old credentials through the final login check. Update the inventory and `HISTORY.md` under `servers//server-notes/` with package and access evidence and open work.