Start Linux server security with access you can recover, then establish individual administrative accounts, apply updates, reduce network exposure and test recovery. Keep the original administrative session open while changing SSH or firewall rules. A successful configuration check is only one step: a new authorised login must work before you retire the previous access path.
This checklist uses Ubuntu Server 24.04 LTS, OpenSSH and UFW as its worked environment. Run server commands individually in an interactive Bash terminal, with a user authorised to use sudo. Client-side actions are labelled separately. The sequence is useful when planning other Linux systems, but their package commands, service names and firewall configuration need their own distribution-specific procedure. Do not apply this Ubuntu example unchanged to a different distribution.
1. Preserve administrative and recovery access
Before editing access controls, establish an independent recovery route for this particular server. Open that route and prove you can use it; a saved address or password is not an access test. If your recovery procedure depends on the same SSH connection you are about to change, it is not independent. Do not proceed with restrictive changes until you have a workable alternative.
Record the server identity, administrator account, current SSH endpoint and the configuration files you intend to change. Keep the original authenticated session open. Make a protected copy of the current SSH configuration, including any snippets you will edit, so recovery means restoring known settings rather than reconstructing them from memory. Ubuntu explicitly warns that a bad SSH configuration can prevent the server from starting and leave a remote administrator locked out.
Use the following order throughout the checklist:
| Stage | Required observation | Undo or recovery action |
|---|---|---|
| Establish a replacement administrator | A fresh login works and the intended administrative command succeeds | Keep the original account and session available; correct the replacement account before restricting anything |
| Change SSH configuration | Configuration validation passes, followed by a fresh authorised login | Restore the changed configuration through the retained session or independent recovery route; validate it before restarting SSH |
| Restrict the host firewall | Required access works from the intended network and unwanted access is blocked | Reverse the specific blocking rule using retained access; repeat the connection test |
| Apply updates | Package operations complete and required application functions still work | Diagnose the failed package or service; use the documented recovery procedure if repair is insufficient |
| Test a restore | Selected files appear in a separate destination with the expected contents | Leave production unchanged; correct the backup or restore procedure and repeat the isolated check |
Scroll horizontally to see the full table.
This is a staged change process, not a guarantee against compromise. Stop at a failed observation instead of continuing through the remaining rows.
2. Establish individual users and SSH authentication
Use an individual account for each administrator and reserve elevated privileges for administration. Ubuntu uses sudo to let authorised users perform privileged tasks; membership of the sudo group grants full administrative access. Do not give that membership to an account that only needs to run an application.
On the server, create the intended administrator with sudo adduser <ADMIN_USER>, replacing <ADMIN_USER> with your chosen account name before execution. Complete its prompts. If this account requires full administration, add it using sudo adduser <ADMIN_USER> sudo. Treat these as separate actions: do not continue if account creation fails, and do not remove the original administrator yet.
On your client computer, create an SSH key if you do not already have an appropriate one. Ubuntu recommends Ed25519 and documents ssh-keygen -t ed25519. Protect the private key; install only its public counterpart for the server account. The documented ssh-copy-id <ADMIN_USER>@<SERVER_HOST> command installs the public key for the named account. Replace both placeholders with the real account and host, and use your existing connection settings if SSH is not on its usual endpoint.
Open a fresh client connection as that account and test an administrative action it genuinely needs. A key passphrase prompt unlocks the local private key; it is different from a server account password prompt. Inspect the target account's authorized_keys permissions: Ubuntu requires that only its owner have write permission. Keep the working original session available while correcting access failures.
For OpenSSH changes, Ubuntu supports the main /etc/ssh/sshd_config file and snippets under /etc/ssh/sshd_config.d/. Most directives take their first configured value, so inspect existing snippets as well as the main file before adding a setting. A later duplicate is not a reliable override.
One documented way to limit SSH access is an AllowGroups rule. Establish the intended group and add every authorised login account before configuring the restriction. Do not paste a group name that does not include your replacement administrator. Preserve the old configuration for rollback and validate the edited configuration on the server:
If validation reports an error, fix it before restarting anything. Once validation succeeds, apply the change using Ubuntu's documented service command:
Now test a genuinely new SSH connection from the intended client, followed by the required administrative action. Do not mistake a reused connection for a new authentication test: SSH connection multiplexing can reuse an existing connection. Only after the replacement path works should you retire obsolete access. If it fails, restore the edited configuration through retained access, validate it and restart the service again.
Removing a user's password does not revoke an installed SSH key. When withdrawing access, review keys and existing sessions as well as passwords and group membership. Changing the SSH port is a separate, narrower task; it does not replace identity controls, patching or firewall restrictions.
3. Apply updates with restarts in mind
Review pending maintenance before installing applications. On this Ubuntu example, refresh package information first:
Resolve repository errors before proceeding. Then run the upgrade interactively, read the proposed changes and approve them only when you are ready for their effect:
Ubuntu's package guidance distinguishes updating the package index from upgrading installed packages. These commands do not upgrade the server to a new Ubuntu release.
An installed update may still require a service restart or reboot to take effect. Ubuntu documents that, starting with 24.04 LTS, needrestart automatically restarts affected services by default, with exclusions. Plan maintenance accordingly; do not assume package installation will leave applications uninterrupted. Afterward, exercise the actual application function you rely on, rather than accepting package-manager success as proof that the application works.
Inspect automatic-update policy in /etc/apt/apt.conf.d/20auto-upgrades and /etc/apt/apt.conf.d/50unattended-upgrades. The latter controls allowed origins, exclusions and optional reboot behaviour. Adding a third-party repository does not automatically add it to the unattended-upgrade policy. Keep an explicit maintenance route for software that policy does not cover.
To inspect what the configured unattended upgrade would do without applying its package changes, run:
Read the listed origins and packages, then inspect subsequent real runs under /var/log/unattended-upgrades. A dry run describes intended actions; it is not evidence that updates were installed. Keep reboot decisions and any deliberately deferred service restarts in the maintenance record.
4. Restrict exposed services and the host firewall
Build an inventory of services that must be reachable, their intended clients and their listening addresses. On the server, inspect TCP and UDP listeners and their associated processes:
Match each unexpected listener to its application before changing anything. A local listening socket establishes that something is listening; it does not establish that a client on another network can reach it. Remove unnecessary software deliberately, reviewing package dependencies and preserving needed configuration and data. Ubuntu recommends removing unneeded packages to reduce the exposed attack surface.
The host firewall in this example is UFW. Inspect its current state with sudo ufw status verbose and its numbered rules with sudo ufw status numbered. Do not assume that an existing server still has the default configuration. Ubuntu documents UFW for IPv4 and IPv6 host filtering and supports rules limited to a particular source host or network.
Before enabling or tightening UFW, add the allow rule for the SSH endpoint you actually use and any other required service. The documented form is sudo ufw allow proto tcp from <ADMIN_IP> to any port <SSH_PORT>. Replace the source address and port with the real administrative source and existing SSH port. Keep broader working access until the restricted route has been tested. If there are other filtering layers in your own network path, include them in that access test.
Use UFW's --dry-run option to inspect a proposed rule without applying it. After applying a rule, inspect the resulting state and try a fresh connection from the allowed location. Also test the unwanted access you intended to block. Test the address families you actually expose. Do not infer that an IPv4 test proves the IPv6 path behaves identically.
If the new rule blocks required access, use the retained administrative or recovery route to reverse that specific change. UFW supports deletion by the rule itself; review the current rules again before deleting by number because the numbering represents the current list. Restore the intended access, repeat the connection test and record what failed. Do not solve a narrow access problem by leaving the entire firewall disabled.
5. Inspect logs after changes
For SSH authentication failures, Ubuntu documents following the service journal:
Keep that view open while attempting the new client connection, then correlate the attempt with the server's messages. Distinguish authentication failure from a connection that never reaches SSH. End the live log view when you have finished inspecting it.
Review package activity in /var/log/dpkg.log and unattended-upgrade logs after maintenance. UFW logging can be enabled with sudo ufw logging on; inspect relevant firewall events alongside the connection you tested. A lack of recorded errors is not a substitute for the functional test.
Keep a baseline of authorised users, expected listeners and working application behaviour. Compare it after each meaningful change and during routine reviews. An unexplained new account or exposed service deserves investigation even when the application still appears to work.
6. Prove that important state can be restored
Write down which application data, configuration and recovery credentials you need, where independent copies live and how to retrieve them without the original host. Our Virtarix VPS and VDS services include one snapshot. That snapshot does not replace customer-owned copies or an independent recovery plan.
Ubuntu's backup guide makes a useful distinction: listing an archive is a check, but restoring a file is a better test. Its tar example uses -C to extract into a different directory rather than overwriting the original path. Adapt that approach to a trusted backup and a new, isolated destination under your control. Inspect archive members and destination identity first; do not extract an untrusted archive or restore over the live system.
For the acceptance check, restore selected important data and configuration into that isolated destination. Open the recovered files and compare their contents and required permissions with the intended state. For a rebuild, use a separate environment that cannot write to production services, and test the recovered application's required functions there. Record missing files, unavailable credentials and unsuccessful steps, then repair the procedure and repeat the test. Recovering one configuration file proves that file's recovery, not recovery of the entire application.
7. Keep the baseline current
Assign an owner to patch review, access review and recovery checks. Revisit them after software installations, account changes and network changes, as well as on your scheduled maintenance cycle. Remove obsolete access, investigate unexpected listeners, review failed updates and repeat recovery checks when important data or configuration changes. The first-login checklist becomes useful long-term when it is a repeatable maintenance record rather than a one-time declaration of security.
With our Cloud VPS, we supply self-managed infrastructure and root access. You install, configure, secure, update and operate the operating system and applications, including credentials, firewall rules and recovery planning. Keep those responsibilities together: access safeguards let you make changes, logs and functional tests show their effects, and independent recovery gives you a way back when repair is not enough.
Plan hosting as one layer of your defence
Review Cloud VPS resources alongside the monitoring, access controls and application defences your service needs.
Compare Cloud VPS plans



