Budget-friendly, full-performance, fully equipped servers in any desired location.
ExploreBudget-friendly, full-performance, fully equipped servers in any desired location.
ExploreFor server security, first record the current state without losing your administrative access. Then keep the system up to date, restrict SSH access, open only the services that are necessary in the firewall, and use a separate administrative account. Applying each change separately and verifying it with a new session helps prevent an incorrect setting from cutting off access or affecting a running service.
This guide is for a Linux VPS or physical server whose operating system and services you manage. With a shared hosting account, you cannot change the operating system firewall, SSH configuration, or system updates; in that case, you can manage only the account, application, and password controls provided in your hosting panel. On a VPS, you should have an administrator or sudo-enabled account as well as access to the provider’s console or an emergency access method.
Before making changes, record the current SSH settings, open services, administrative accounts, and the provider’s recovery option. If possible, back up the configuration files and take a current backup of the application data. Do not change the SSH settings over your only active connection; keep a second session ready. If a problem occurs after changing a setting, returning first to the value you recorded is safer than making random additional changes.
A read-only command such as ss -tulpen in an administrative terminal shows which TCP or UDP ports are listening. Consider the output as an example: ports 80 and 443 may be open for a web server, while SSH may use port 22; a database port listening on all network interfaces should also be investigated. The format of this command may vary depending on your distribution and permissions; the goal is not to memorize the command, but to distinguish an unnecessary service exposed externally.
If SSH is used only for administration, switch to key-based login and verify that you can open a separate session with a new sudo-enabled account. Then consider disabling the option that permits direct root login in the SSH configuration and, after your key access is genuinely working, disabling password login. The decision is clear: if key authentication succeeds in a new session and your recovery access is ready, you can reduce the password-based attack surface; if login with the new account fails, do not disable this setting. Fix the key, user, and sudo permissions first.
Check the operating system’s package manager for pending security updates and for kernel or service updates that require a restart. Evaluate application dependencies separately from operating system packages; updating the system does not mean that your application’s plugins or runtime are up to date. First prepare the maintenance window, the backup, and access to the provider’s console.
The basic order matters in the firewall: first allow the existing SSH administration path, then allow the ports that the web application actually uses, and finally enable the default policy that blocks unnecessary incoming connections. If it is possible to restrict the administration port to specific office or VPN addresses, apply this only after confirming that those addresses will not change. After adding a rule, retry the SSH connection and web address from a new terminal. If SSH is interrupted, use the provider’s console to undo the previous rule change; instead of disabling the firewall completely, correct the faulty rule.
Separate the directories where the web application needs to write files from the directories containing system configuration. Give the application user write permission only for the files and directories it needs; do not grant broad write permission to the entire file system or to every user. If a service runs as root, check whether the service manager’s unit configuration provides an option to switch to a more limited user and whether the application is compatible with that change. Changing ownership across a whole group of files can break a running application, so it is not a safe correction without evidence.
Suppose a web application creates an “access denied” entry during an upload. This entry does not indicate that you need to loosen permissions across the entire server. First note the time of the error and find which directory cannot be written to in the relevant application log; if the directory is the temporary or upload area expected by the application, correct only the service user and group permissions for that area. Retry the same upload and check for a new, time-matching entry. If the error points to another configuration file, do not generalize from the first finding; restore the previous permission values and investigate that file’s ownership separately.
Failed SSH logins, sudo use, firewall blocks, and web server errors may be recorded in different logs. Review recent events within the same time range through the distribution’s log viewer, service management tool, or the hosting provider’s server panel. A single failed login entry is not definitive proof of an attack; if there are repeated attempts within a short period, an unknown source, or an unexpected administrative action, review the access keys and account list separately as well. When you find a suspicious key, remove only the relevant key; do not randomly delete every user.
A backup is meaningful not merely because it was created, but because it can be restored. Check that database and file backups are stored in another location, that the access credentials are not tied to the only account on the server, and that you know an example restoration procedure. If a backup fails, first distinguish the cause by checking the storage quota, authentication, and scheduled-task logs; do not delete older backups until the problem is resolved.
First open a separate SSH session with the new administrative account; if it succeeds, do not immediately close the existing session. Verify the sudo permissions and console access as well. Then check the firewall permissions and confirm that only the expected ports are reachable. If the web service responds but SSH does not, do not change the application settings; undo the latest firewall or SSH change and try again with a new session.
Next, after the update, run a small test of the application’s real operations, such as login, file upload, and, where necessary, database connectivity. After each operation, look for the new log line; an old entry does not prove that the change succeeded or failed. If you see multiple problems, roll back only one factor and test again. When evaluating managed infrastructure, additional monitoring, or server options, you may use the server rental options page only to review the available options.
The next safe step is to record the open ports, administrative accounts, update status, and restoration procedure for your server in a one-page inventory, including dates. Whenever you add a new service, write down the reason for adding it and the firewall rule that opened it; this makes forgotten access visible during the next review.
Copyright © 2026 All Rights Reserved
