Field note
Change SSH Authentication Without Lockout
A secure SSH change still needs a tested way back into the server.
Removing an unnecessary SSH authentication method is a sensible change when the remaining access route works and the effect is understood. On a remote server, the most useful preparation is a verified alternative console, a copy of the current configuration and a test plan for fresh connections.
Start with the actual access requirement. Identify administrators, automation, file-transfer users and any emergency account. Decide which methods each needs and from which networks. A server supporting several purposes may need account-specific rules rather than one global setting.
Read the effective configuration
OpenSSH normally uses the first obtained value for a configuration keyword. Included files and conditional Match blocks can therefore change the effect of an edit. Adding a directive at the bottom of the main file does not prove that it becomes effective. The sshd_config manual defines the evaluation rules.
Ubuntu, for example, normally includes /etc/ssh/sshd_config.d/*.conf near the top of its configuration. Its OpenSSH server documentation explains why a snippet can take precedence over the main file. Check the installed distribution's documentation and files rather than assuming identical packaging everywhere.
On a typical Linux host with the binary in /usr/sbin, these commands validate and display configuration without starting a new listener:
sudo /usr/sbin/sshd -t
sudo /usr/sbin/sshd -T -C user=opsadmin,host=admin-laptop.example,addr=192.0.2.50
Use a real intended account and connection context. The sshd manual documents syntax checking and extended tests with connection parameters. Repeat the effective-configuration check for account groups or source networks affected by different Match rules.
Decide what the authentication change actually removes
Review password authentication, keyboard-interactive authentication, public-key authentication and any required combination. Keyboard-interactive authentication may be part of an MFA integration. Removing it without checking the authentication chain can disable the factor you intended to preserve.
Likewise, possession of a public key does not establish that the user can complete an administrative task. Verify the account's permissions and the supported privilege-elevation route. If you intend to restrict direct root login, confirm that authorised staff can sign in through their own accounts and obtain the privileges needed for recovery.
Check unattended clients separately. A backup process may run from a different source address or use a restricted command. An administrator's successful login from the office does not validate that path.
Record the intended effective settings for each access type before editing. That provides a precise result to compare with the post-change output and avoids judging success by whether the file contains the expected words.
Apply one bounded change
Preserve the relevant main file, snippets and management configuration. If configuration management owns them, make the change there so a later run does not restore the old policy.
Confirm the alternative console or provider recovery method while the server is healthy. Know whether it requires separate credentials, a restart or supplier intervention. Keeping the current SSH session open is useful during a controlled change, but it is not a replacement for a functioning recovery route.
Validate the edited configuration before using the distribution's supported reload or restart procedure. Understand the procedure's effect on the service and schedule the work accordingly. Avoid changing authentication, the listening port, firewall rules and routing at the same time; each introduces a different possible reason for a failed connection.
Open a new session from an approved client and perform a harmless administrative check. Confirm the intended method in the authentication evidence, then test that the retired method is refused. Keep repeated attempts limited so you do not trigger unrelated lockout or abuse controls.
Close the loop with a new connection
Test each important access path, including the recovery account and required automation. If a path fails, inspect the effective configuration and logs before making additional edits. Use the preserved configuration and recovery route if the change cannot be completed safely within the window.
Record what was changed, which fresh connections were checked and which methods were refused. Remove any temporary access granted for the work. Review the result after the next deployment or image rebuild, because a hand-edited server can drift from the configuration used to create its replacement.
The finished change should leave a clear account-to-method mapping and a usable recovery procedure. Those records make the next access review or server replacement considerably easier to assess.
References
- OpenSSH, sshd_config manual. Accessed 17 October 2026.
- OpenSSH, sshd manual. Accessed 17 October 2026.
- Canonical, OpenSSH server configuration on Ubuntu. Accessed 17 October 2026.
Related notes
12 Jan 2026 · 3 min
17 Oct 2026 · 4 min
17 Oct 2026 · 5 min
Need help mapping this to your own tenant, controls, or assessment timeline?