{"id":53874,"date":"2022-05-05T13:12:54","date_gmt":"2022-05-05T13:12:54","guid":{"rendered":"\/tutorials\/?p=53874"},"modified":"2026-11-23T04:03:06","modified_gmt":"2026-11-23T04:03:06","slug":"vps-security","status":"publish","type":"post","link":"\/ng\/tutorials\/vps-security\/","title":{"rendered":"VPS security: How to secure your Linux VPS"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p class=\"wp-block-paragraph\">To secure your Linux virtual private server (VPS), protect administrative access and keep the operating system and software patched. Then limit unnecessary internet exposure and maintain backups you can restore.<\/p><p class=\"wp-block-paragraph\">VPS security means protecting your server, the software you run on it, and its data from unauthorized access, exploitation, malware, and data loss. On a self-managed VPS, you configure and maintain these protections yourself.<\/p><p class=\"wp-block-paragraph\">Follow these VPS hardening steps in order:<\/p><ol class=\"wp-block-list\">\n<li>Create a non-root account for administration.<\/li>\n\n\n\n<li>Set up SSH keys, then restrict password and root logins.<\/li>\n\n\n\n<li>Add Fail2Ban if you see repeated failed login attempts.<\/li>\n\n\n\n<li>Patch the operating system, packages, applications, and dependencies.<\/li>\n\n\n\n<li>Restrict inbound traffic with a firewall.<\/li>\n\n\n\n<li>Keep internal services from listening publicly.<\/li>\n\n\n\n<li>Protect app secrets and limit file and account permissions.<\/li>\n\n\n\n<li>Watch authentication, system, and app logs for suspicious activity.<\/li>\n\n\n\n<li>Scan for malware or unexpected files when relevant to your workload.<\/li>\n\n\n\n<li>Automate backups and test the restore process.<\/li>\n<\/ol><p class=\"wp-block-paragraph\"><\/p><h2 id=\"h-is-a-vps-secure\" class=\"wp-block-heading h-t-title-2\">Is a VPS secure?<\/h2><p class=\"wp-block-paragraph\">Yes, a VPS is secure at the infrastructure layer because virtualization isolates it from other VPS instances. Each VPS runs its own operating system and server environment, so other VPS users can&rsquo;t access your accounts, files, or system configuration.<\/p><p class=\"wp-block-paragraph\">That isolation doesn&rsquo;t automatically secure what runs inside your VPS, though. You still need to install security updates, secure SSH access, close unnecessary ports, and protect credentials stored by your apps.<\/p><p class=\"wp-block-paragraph\">Securing a VPS is a shared responsibility between you and your VPS provider. Your provider secures the infrastructure that runs and isolates the VPS, while you secure everything you install, configure, and expose on your server.<\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>VPS provider<\/strong><\/td><td><strong>VPS owner<\/strong><\/td><\/tr><tr><td>Physical infrastructure<\/td><td>OS and package updates<\/td><\/tr><tr><td>Virtualization and VPS isolation<\/td><td>SSH and account security<\/td><\/tr><tr><td>Host networking<\/td><td>Firewall rules and exposed services<\/td><\/tr><tr><td>Provider-level security tools<\/td><td>App configuration<\/td><\/tr><tr><td>Management platform<\/td><td>Credentials, secrets, and permissions<\/td><\/tr><tr><td>Infrastructure-level protections<\/td><td>Monitoring and maintenance<\/td><\/tr><tr><td>Backup tooling<\/td><td>Backup configuration and restore testing<\/td><\/tr><\/tbody><\/table><\/figure><p class=\"wp-block-paragraph\"><a data-click-id=\"hgr-post-content-link-hostinger-vps-hosting\" href=\"\/ng\/vps-hosting\">Hostinger VPS hosting<\/a> follows this model as a self-managed environment. Its VPS plans use Kernel-based Virtual Machine (KVM) virtualization, which gives each VPS its own kernel and allocated resources.<\/p><p class=\"wp-block-paragraph\">Hostinger handles the underlying infrastructure and provides management tools for firewall rules, malware scanning, backups, and recovery.<\/p><p class=\"wp-block-paragraph\">This VPS hardening baseline addresses three common risks: weak or stolen credentials, outdated software with known vulnerabilities, and services exposed to the internet unnecessarily.<\/p><p class=\"wp-block-paragraph\"><a data-click-id=\"hgr-post-content-link-set-up-a-vps\" href=\"\/ng\/tutorials\/how-to-set-up-vps\/\">Set up a VPS<\/a> before applying the hardening steps if you haven&rsquo;t finished the initial server configuration.<\/p><figure class=\"wp-block-image size-large\"><a data-click-id=\"hgr-post-content-link-ng-vps-hosting\" aria-label=\"Vps hosting\" class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ng\/vps-hosting\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<h2 id=\"h-1-create-a-non-root-administrative-user\" class=\"wp-block-heading h-t-title-2\">1. Create a non-root administrative user<\/h2><p class=\"wp-block-paragraph\">Create a dedicated non-root administrative user by adding a new account to the <strong>sudo<\/strong> group on Debian and Ubuntu or the <strong>wheel<\/strong> group on Red Hat Enterprise Linux (RHEL)-family distributions.<\/p><p class=\"wp-block-paragraph\">You&rsquo;ll use regular user permissions by default and run <strong>sudo<\/strong> only when a command needs administrator access.<\/p><p class=\"wp-block-paragraph\">This follows the principle of least privilege by giving each user only the permissions they need. It reduces the impact of accidental commands and limits how many accounts have unrestricted control over your VPS.<\/p><p class=\"wp-block-paragraph\">Review the <a data-click-id=\"hgr-post-content-link-current-linux-user-accounts\" href=\"\/ng\/tutorials\/how-to-list-users-in-linux\/\">current Linux user accounts<\/a> before changing administrator access on an existing VPS.<\/p><p class=\"wp-block-paragraph\">Create a separate administrative account for each person who manages the server. Individual accounts let you revoke one person&rsquo;s access without affecting other administrators and make <strong>sudo<\/strong> activity easier to trace to a specific user.<\/p><p class=\"wp-block-paragraph\">Keep your current <strong>root<\/strong> session open while you create and test the new account. Run the following commands as <strong>root<\/strong>, or add <strong>sudo<\/strong> before them if you&rsquo;re already using another administrative account.<\/p><p class=\"wp-block-paragraph\">On Debian and Ubuntu, create the new user:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">adduser your-username<\/pre><p class=\"wp-block-paragraph\">The command creates the account and home directory, then prompts you to set a password and optionally enter user information before confirming the account details.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c7c39a&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c7c39a\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/1-create-non-root-user-ubuntu.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal running the adduser command to create a non-root user, set a password, and confirm optional account information.\" class=\"wp-image-162225\" style=\"aspect-ratio:2.1152542372881356;width:624px;height:auto\" title=\"1-create-non-root-user-ubuntu\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Confirm that your system has <strong>sudo<\/strong> before granting administrator access. Ubuntu includes it by default, while some Debian installations don&rsquo;t:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">command -v sudo<\/pre><p class=\"wp-block-paragraph\">Install <strong>sudo<\/strong> if the command returns no path:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apt update\napt install sudo<\/pre><p class=\"wp-block-paragraph\">Then add the newly created user to the <strong>sudo<\/strong> group:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">usermod -aG sudo your-username<\/pre><p class=\"wp-block-paragraph\">On RHEL-family distros, including RHEL, Rocky Linux, and AlmaLinux, create the user:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">useradd -m your-username<\/pre><p class=\"wp-block-paragraph\">Set its password:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">passwd your-username<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c7f968&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c7f968\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/2-create-non-root-user-almalinux.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal creating a non-root user with useradd -m and setting the account password with passwd.\" class=\"wp-image-162226\" style=\"aspect-ratio:3.7365269461077846;width:624px;height:auto\" title=\"2-create-non-root-user-almalinux\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Then add the user to the <strong>wheel<\/strong> group, which grants <strong>sudo<\/strong> access on standard RHEL-family configurations:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">usermod -aG wheel your-username<\/pre><p class=\"wp-block-paragraph\">Verify the new account before restricting any existing administrator access. Switch to the new user and test <strong>sudo<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">su - your-username\nsudo whoami<\/pre><p class=\"wp-block-paragraph\">Enter the new user&rsquo;s password when prompted. The <strong>sudo whoami<\/strong> command should return <strong>root<\/strong>, confirming that the account has administrator access.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c834ac&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c834ac\" class=\"aligncenter size-full is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/3-verify-sudo-access-ubuntu.png\/public\" alt=\"Ubuntu terminal switching to the new non-root user and running sudo whoami, which returns root to confirm administrative access.\" class=\"wp-image-162227\" style=\"aspect-ratio:4.489208633093525;width:624px;height:auto\" title=\"3-verify-sudo-access-ubuntu\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Fix the new account&rsquo;s <strong>sudo<\/strong> access first if the command doesn&rsquo;t return <strong>root<\/strong>.<\/p><h2 id=\"h-2-use-ssh-keys-and-restrict-password-and-root-logins\" class=\"wp-block-heading h-t-title-2\">2. Use SSH keys and restrict password and root logins<\/h2><p class=\"wp-block-paragraph\">To use SSH keys, generate the key pair locally, add the public key to your non-root administrative account, and disable password authentication and direct root login only after you verify that key-based access works.<\/p><p class=\"wp-block-paragraph\">Keep your current SSH session open until you&rsquo;ve tested the final configuration so you don&rsquo;t lock yourself out.<\/p><p class=\"wp-block-paragraph\">Generate the key pair on your local computer and <a data-click-id=\"hgr-post-content-link-set-up-ssh-keys\" href=\"\/ng\/tutorials\/how-to-set-up-ssh-keys\/\">set up SSH keys<\/a> for the non-root account you created earlier. Keep the private key on your computer and protect it with a passphrase.<\/p><p class=\"wp-block-paragraph\">From your local computer, copy the public key to your non-root administrative account, not only to <strong>root<\/strong>. A key added only to <strong>root<\/strong> won&rsquo;t give you access once you disable root login later in this step.<\/p><p class=\"wp-block-paragraph\">Replace <strong>your-username<\/strong> with your non-root administrative username and <strong>your-vps-ip<\/strong> with your VPS IP address:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh-copy-id -i ~\/.ssh\/id_ed25519.pub your-username@your-vps-ip<\/pre><p class=\"wp-block-paragraph\">Enter the non-root user&rsquo;s password when prompted. Replace <strong>~\/.ssh\/id_ed25519.pub<\/strong> if you saved the public key under a different file name.<\/p><p class=\"wp-block-paragraph\">Then open a second terminal window and confirm that key authentication works:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh -o PreferredAuthentications=publickey your-username@your-vps-ip<\/pre><p class=\"wp-block-paragraph\">Continue only after the command logs you in with the non-root account. Keep this working key-based session and your original SSH session open while you change the authentication settings.<\/p><p class=\"wp-block-paragraph\">Create a separate SSH configuration file for the hardening settings using the <a data-click-id=\"hgr-post-content-link-nano-text-editor\" href=\"\/ng\/tutorials\/how-to-install-and-use-nano-text-editor\/\">nano text editor<\/a>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/ssh\/sshd_config.d\/00-hardening.conf<\/pre><p class=\"wp-block-paragraph\">Set these values:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">PubkeyAuthentication yes\nPasswordAuthentication no\nKbdInteractiveAuthentication no\nPermitRootLogin no<\/pre><p class=\"wp-block-paragraph\"><strong>PubkeyAuthentication yes<\/strong> keeps SSH key login enabled. <strong>PasswordAuthentication no<\/strong> disables password authentication, <strong>KbdInteractiveAuthentication no<\/strong> disables keyboard-interactive authentication, and <strong>PermitRootLogin no<\/strong> blocks direct SSH login as <strong>root<\/strong>.<\/p><p class=\"wp-block-paragraph\">Set <strong>KbdInteractiveAuthentication<\/strong> to yes instead if your multi-factor authentication (MFA) setup uses it for an additional verification step.<\/p><p class=\"wp-block-paragraph\">Save the file and exit <strong>nano<\/strong> by pressing <strong>Ctrl + X<\/strong> &rarr; <strong>Y<\/strong> &rarr; <strong>Enter<\/strong>.<\/p><div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg aria-hidden=\"true\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Expert tip\n                <\/p>\n            <\/div>\n            <p class=\"protip__content\">OpenSSH reads files in <strong>\/etc\/ssh\/sshd_config.d\/<\/strong> before the main <strong>sshd_config<\/strong> file and uses the first value it reads for most settings. Naming the file <strong>00-hardening.conf<\/strong> makes it load before common later-named drop-in files, while <strong>sshd -T<\/strong> confirms the effective configuration before you reload SSH.<\/p>\n                <div class=\"protip__expert\">\n                    <div class=\"protip__expert-image\">\n                        <img loading=\"lazy\" decoding=\"async\" width=\"48\" height=\"48\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/07\/minijus-savickas.jpg\/w=65,h=65,fit=scale-down\" alt=\"Editor\" \/>\n                    <\/div>\n                    <div>\n                        <p class=\"protip__expert-name\">Minijus Savickas<\/p>\n                        <p class=\"protip__expert-position\">VPS Product Manager<\/p>\n                    <\/div>\n                <\/div>\n        <\/div>\n\n\n\n<\/p><p class=\"wp-block-paragraph\">Check the configuration for syntax errors before applying the changes:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo sshd -t<\/pre><p class=\"wp-block-paragraph\">No output means the configuration passed the syntax check. Fix any reported error before continuing.<\/p><p class=\"wp-block-paragraph\">Next, confirm which authentication settings OpenSSH will use:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo sshd -T | grep -E 'pubkeyauthentication|passwordauthentication|kbdinteractiveauthentication|permitrootlogin'<\/pre><p class=\"wp-block-paragraph\">The output should show:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">permitrootlogin no\npubkeyauthentication yes\npasswordauthentication no\nkbdinteractiveauthentication no<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c87043&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c87043\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/4-verify-ssh-hardening-settings.png\/w=1024,h=1024,fit=scale-down\" alt=\"Terminal output from sshd -T showing public-key authentication enabled and password, keyboard-interactive, and root SSH logins disabled.\" class=\"wp-image-162228\" style=\"aspect-ratio:8.788732394366198;width:624px;height:auto\" title=\"4-verify-ssh-hardening-settings\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">RHEL 8.6 and later support SSH drop-in configuration files. On RHEL 8.5 and earlier, edit <strong>\/etc\/ssh\/sshd_config<\/strong> directly instead of relying on <strong>\/etc\/ssh\/sshd_config.d\/<\/strong>.<\/p><p class=\"wp-block-paragraph\">Don&rsquo;t reload SSH if <strong>sudo sshd -T<\/strong> doesn&rsquo;t show the expected settings. Resolve the conflicting configuration first, then run <strong>sudo sshd -t<\/strong> and <strong>sudo sshd -T<\/strong> again.<\/p><p class=\"wp-block-paragraph\">Reload SSH after both checks succeed. Run the following command on Debian and Ubuntu:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl reload ssh<\/pre><p class=\"wp-block-paragraph\">Use <strong>sshd<\/strong> as the service name on RHEL-family distros:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl reload sshd<\/pre><p class=\"wp-block-paragraph\">Open another local terminal and test the non-root account again:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh -o PreferredAuthentications=publickey your-username@your-vps-ip<\/pre><p class=\"wp-block-paragraph\">Run <strong>sudo whoami<\/strong> after logging in. Close your original SSH session only after the key-based login succeeds and <strong>sudo whoami<\/strong> returns <strong>root<\/strong>.<\/p><p class=\"wp-block-paragraph\">Use Hostinger&rsquo;s recovery options if an SSH configuration error locks you out. In the Hostinger dashboard, open <strong>VPS &rarr; Manage &rarr; Overview &rarr; Web console<\/strong> for browser-based server access.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c8be0a&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c8be0a\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/5-open-hostinger-vps-web-console.png\/w=1024,h=1024,fit=scale-down\" alt=\"Hostinger VPS Overview page showing a running Ubuntu VPS and the Web console button for browser-based server access.\" class=\"wp-image-162229\" style=\"aspect-ratio:2.0594059405940595;width:624px;height:auto\" title=\"5-open-hostinger-vps-web-console\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Hostinger Agent in the web console can also inspect the SSH configuration while troubleshooting the connection.<\/p><p class=\"wp-block-paragraph\">Alternatively, go to <strong>VPS &rarr; Manage &rarr; Settings &rarr; Main settings &rarr; Reset SSH<\/strong> to restore the default SSH configuration.<\/p><p class=\"wp-block-paragraph\">Use <strong>Reset firewall configuration<\/strong> in the same section to restore the default firewall rules if a Hostinger firewall rule blocks your SSH connection instead.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c8ef3a&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c8ef3a\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/6-reset-ssh-firewall-hostinger.png\/w=1024,h=1024,fit=scale-down\" alt=\"Hostinger VPS Main settings page showing options to reset the firewall configuration and SSH configuration.\" class=\"wp-image-162230\" style=\"aspect-ratio:2.0869565217391304;width:624px;height:auto\" title=\"6-reset-ssh-firewall-hostinger\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Use stronger access restrictions only when your setup requires them. Restrict SSH to trusted source IP addresses for administrators with fixed IPs, use a VPN to keep administrative access on a private network, or route access through a bastion host when you manage multiple servers.<\/p><p class=\"wp-block-paragraph\"><a data-click-id=\"hgr-post-content-link-changing-the-ssh-port\" href=\"\/ng\/tutorials\/how-to-change-ssh-port-vps\/\">Changing the SSH port<\/a> also reduces automated scans and failed-login noise aimed at port <strong>22<\/strong>. It doesn&rsquo;t strengthen authentication or replace SSH keys or root-login restrictions.<\/p><p class=\"wp-block-paragraph\">Allow the new SSH port in every active firewall layer before switching. Otherwise, you can lock yourself out.<\/p><p class=\"wp-block-paragraph\">On Ubuntu systems that use systemd socket activation, changing the SSH port also requires reloading systemd and restarting <strong>ssh.socket<\/strong> for the new port to take effect.<\/p><h2 id=\"h-3-use-fail2ban-when-there-are-repeated-login-attempts\" class=\"wp-block-heading h-t-title-2\">3. Use Fail2Ban when there are repeated login attempts<\/h2><p class=\"wp-block-paragraph\">Add Fail2Ban to SSH or another publicly reachable login service after you see repeated failed login attempts in its logs. Fail2Ban monitors those failures and temporarily blocks the source IP after the number of attempts reaches the configured retry limit.<\/p><p class=\"wp-block-paragraph\">For SSH, enable the <strong>sshd<\/strong> jail. A jail tells Fail2Ban which service to monitor and how many failed authentication attempts trigger an IP block.<\/p><p class=\"wp-block-paragraph\">Install Fail2Ban on Debian and Ubuntu with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update\nsudo apt install fail2ban<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c92f67&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c92f67\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/7-install-fail2ban-ubuntu.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal installing Fail2Ban and its dependencies with APT.\" class=\"wp-image-162231\" style=\"aspect-ratio:2.0259740259740258;width:624px;height:auto\" title=\"7-install-fail2ban-ubuntu\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">On RHEL-family distros such as Rocky Linux and AlmaLinux, enable the Extra Packages for Enterprise Linux (EPEL) repository first:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf install epel-release\nsudo dnf install fail2ban<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c965ca&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c965ca\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/8-install-fail2ban-almalinux.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal showing Fail2Ban and its required firewall and networking packages installed successfully with DNF.\" class=\"wp-image-162232\" style=\"aspect-ratio:1.250501002004008;width:624px;height:auto\" title=\"8-install-fail2ban-almalinux\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Create <strong>\/etc\/fail2ban\/jail.d\/sshd.local<\/strong> to enable the SSH jail without changing Fail2Ban&rsquo;s default configuration files:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/fail2ban\/jail.d\/sshd.local<\/pre><p class=\"wp-block-paragraph\">Add:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[sshd]\nenabled = true<\/pre><p class=\"wp-block-paragraph\">On Debian 12, also set the SSH jail to read authentication events from the systemd journal because <strong>\/var\/log\/auth.log<\/strong> isn&rsquo;t available on a default installation:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[sshd]\nenabled = true\nbackend = systemd<\/pre><p class=\"wp-block-paragraph\">Save the file and exit <strong>nano<\/strong>. Fail2Ban will then watch SSH authentication failures and tell the server firewall to block an IP after too many failed attempts.<\/p><p class=\"wp-block-paragraph\">Keep your current SSH session open while testing so you still have access if Fail2Ban blocks your own IP.<\/p><p class=\"wp-block-paragraph\">Enable Fail2Ban at startup and restart it to apply the configuration:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl enable fail2ban\nsudo systemctl restart fail2ban<\/pre><p class=\"wp-block-paragraph\">Confirm that Fail2Ban is running:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status fail2ban --no-pager<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c99879&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c99879\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/9-verify-fail2ban-service-status.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal showing fail2ban.service as active (running) in the systemd service status.\" class=\"wp-image-162233\" style=\"aspect-ratio:2.8363636363636364;width:624px;height:auto\" title=\"9-verify-fail2ban-service-status\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Continue when the output shows <strong>active (running)<\/strong>, then check the SSH jail:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo fail2ban-client status sshd<\/pre><p class=\"wp-block-paragraph\">The <strong>fail2ban-client status sshd<\/strong> command should show the <strong>sshd<\/strong> jail status and its failed-login and banned-IP counts.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169c9cc21&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169c9cc21\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/10-check-fail2ban-sshd-jail.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal showing the Fail2Ban sshd jail status, including failed login and banned IP counts.\" class=\"wp-image-162234\" style=\"aspect-ratio:4.303448275862069;width:624px;height:auto\" title=\"10-check-fail2ban-sshd-jail\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\"><a data-click-id=\"hgr-post-content-link-configure-fail2ban\" href=\"\/ng\/tutorials\/fail2ban-configuration\/\">Configure Fail2Ban<\/a> further to allowlist trusted administrative IPs, adjust ban thresholds, or protect other login services that record authentication failures.<\/p><p class=\"wp-block-paragraph\">Fail2Ban complements SSH keys and firewall rules rather than replacing them. SSH keys strengthen authentication, firewall rules control which traffic reaches the VPS, and Fail2Ban reacts to repeated failed logins that still reach a monitored service.<\/p><p class=\"wp-block-paragraph\">However, Fail2Ban isn&rsquo;t general DDoS protection. It blocks IPs only after matching events appear in server logs, so it won&rsquo;t stop a large traffic flood before it reaches your VPS.<\/p><h2 id=\"h-4-keep-the-vps-and-its-software-patched\" class=\"wp-block-heading h-t-title-2\">4. Keep the VPS and its software patched<\/h2><p class=\"wp-block-paragraph\">Keep your VPS and its software patched by updating the operating system, system packages, apps, and dependencies as security fixes become available.<\/p><p class=\"wp-block-paragraph\">Refresh the available package list and <a data-click-id=\"hgr-post-content-link-install-updates-on-ubuntu\" href=\"\/ng\/tutorials\/how-to-update-ubuntu\/\">install updates on Ubuntu<\/a> and Debian with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update\nsudo apt upgrade<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169ca07f8&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169ca07f8\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/11-update-ubuntu-packages.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal running APT updates and showing the package upgrade summary.\" class=\"wp-image-162235\" style=\"aspect-ratio:2.943396226415094;width:624px;height:auto\" title=\"11-update-ubuntu-packages\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">On RHEL-family distros, update installed packages with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf upgrade<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169ca3992&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169ca3992\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/12-update-almalinux-packages.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal showing a completed DNF upgrade with updated kernel and system packages installed.\" class=\"wp-image-162236\" style=\"aspect-ratio:5.724770642201835;width:624px;height:auto\" title=\"12-update-almalinux-packages\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">These commands update software installed through <strong>apt<\/strong> or <strong>dnf<\/strong>, including kernel packages when newer versions are available.<\/p><p class=\"wp-block-paragraph\">Review the proposed changes before confirming them, especially when they affect your web server, database, PHP, Node.js, or other software your site or app relies on.<\/p><p class=\"wp-block-paragraph\">Check whether the VPS needs a reboot after installing updates. On Debian and Ubuntu, check for the <strong>\/run\/reboot-required<\/strong> file:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">test -f \/run\/reboot-required &amp;amp;&amp;amp; cat \/run\/reboot-required || echo \"No reboot required\"<\/pre><p class=\"wp-block-paragraph\">On RHEL-family distros, install <strong>dnf-plugins-core<\/strong> if <strong>needs-restarting<\/strong> isn&rsquo;t available:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf install dnf-plugins-core<\/pre><p class=\"wp-block-paragraph\">Then check whether a reboot is required:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf needs-restarting -r<\/pre><p class=\"wp-block-paragraph\">Reboot the VPS when required:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo reboot<\/pre><p class=\"wp-block-paragraph\">Plan the reboot for a low-traffic or scheduled maintenance period if temporarily taking the server offline would affect users.<\/p><p class=\"wp-block-paragraph\">Next, decide how you&rsquo;ll keep the system patched over time. Automate security updates if you don&rsquo;t need to review every update manually.<\/p><p class=\"wp-block-paragraph\">On Debian and Ubuntu, first check whether <strong>unattended-upgrades<\/strong> is installed:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">dpkg -s unattended-upgrades<\/pre><p class=\"wp-block-paragraph\">Install it if the command reports that the package isn&rsquo;t installed:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update\nsudo apt install unattended-upgrades<\/pre><p class=\"wp-block-paragraph\">Then enable automatic updates:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dpkg-reconfigure unattended-upgrades<\/pre><p class=\"wp-block-paragraph\">Select <strong>Yes<\/strong> when prompted. This turns on automatic updates using the rules configured in <strong>unattended-upgrades<\/strong>.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cad591&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cad591\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/13-enable-unattended-upgrades-ubuntu.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu unattended-upgrades configuration dialog with Yes selected to enable automatic updates.\" class=\"wp-image-162237\" style=\"aspect-ratio:2.7012987012987013;width:624px;height:auto\" title=\"13-enable-unattended-upgrades-ubuntu\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">On RHEL-family distros, install <strong>dnf-automatic<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf install dnf-automatic<\/pre><p class=\"wp-block-paragraph\">Open its configuration file:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/dnf\/automatic.conf<\/pre><p class=\"wp-block-paragraph\">Set <strong>upgrade_type = security<\/strong> under <strong>[commands]<\/strong> so it installs security updates rather than all available updates. Save <strong>automatic.conf<\/strong>, then enable its automatic update schedule:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl enable --now dnf-automatic-install.timer<\/pre><p class=\"wp-block-paragraph\">Keep security updates manual if you prefer to review changes before installing them. This gives you more control over updates that could affect your site or app.<\/p><p class=\"wp-block-paragraph\">Also check that your Linux release still receives security updates. Find the installed distro and version with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat \/etc\/os-release<\/pre><p class=\"wp-block-paragraph\">Upgrade to a supported OS release before your current version stops receiving security updates. Depending on your distro and hosting setup, you can either perform an in-place release upgrade or reinstall the VPS with a newer supported OS.<\/p><p class=\"wp-block-paragraph\">On Ubuntu Server, for example, moving from one Long Term Support (LTS) release to the next is a separate OS upgrade rather than a normal <strong>apt upgrade<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo do-release-upgrade<\/pre><p class=\"wp-block-paragraph\">Treat a major OS upgrade more carefully than routine package updates because it can remove packages, change configuration files, or make existing apps incompatible.<\/p><p class=\"wp-block-paragraph\">Review the new release notes and take a snapshot of your VPS before starting the upgrade so you have a recovery option if something breaks.<\/p><p class=\"wp-block-paragraph\">System updates only cover software installed through <strong>apt<\/strong> or <strong>dnf<\/strong>. A patched operating system can still run vulnerable apps, plugins, libraries, or containers that you need to update separately.<\/p><p class=\"wp-block-paragraph\">For example:<\/p><ul class=\"wp-block-list\">\n<li>Update content management system (CMS) cores, themes, and plugins through the CMS itself or its supported command-line tool.<\/li>\n\n\n\n<li>Check Node.js dependencies with <strong>npm outdated<\/strong>, Python packages with <code>python -m pip list --outdated<\/code>, and PHP dependencies managed by Composer with <strong>composer outdated<\/strong>. Apply dependency updates to a staging copy first when possible, then check that the app starts, its main functions work, and the logs show no new errors.<\/li>\n\n\n\n<li>Update manually installed apps and control panels using their vendor-supported update process.<\/li>\n\n\n\n<li>Update container images and recreate the affected containers because updating the VPS itself doesn&rsquo;t update software inside existing container images.<\/li>\n<\/ul><h2 id=\"h-5-configure-a-firewall\" class=\"wp-block-heading h-t-title-2\">5. Configure a firewall<\/h2><p class=\"wp-block-paragraph\">Configure your VPS firewall to block unsolicited inbound traffic by default, then allow only the ports required by the services you expose.<\/p><p class=\"wp-block-paragraph\">Start by checking which services are listening for network connections:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ss -tulpn<\/pre><p class=\"wp-block-paragraph\">Check the <strong>Local Address<\/strong> and process for each entry. An address of <strong>0.0.0.0<\/strong> means the service listens on all IPv4 addresses assigned to the VPS, <strong>[::]<\/strong> means it listens on all IPv6 addresses, and <strong>127.0.0.1<\/strong> or <strong>::1<\/strong> limits access to the VPS itself.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cb0b26&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cb0b26\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/14-check-listening-ports-ubuntu.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal output of ss -tulpn showing SSH listening publicly on port 22 and other services bound to local addresses.\" class=\"wp-image-162238\" style=\"aspect-ratio:3.6923076923076925;width:624px;height:auto\" title=\"14-check-listening-ports-ubuntu\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Decide which listening ports need connections from outside the VPS. For example, a database used only by an app on the same VPS doesn&rsquo;t need a public firewall rule.<\/p><p class=\"wp-block-paragraph\">On Ubuntu and Debian, <a data-click-id=\"hgr-post-content-link-configure-uncomplicated-firewall-ufw\" href=\"\/ng\/tutorials\/how-to-configure-firewall-on-ubuntu-using-ufw\/\">configure Uncomplicated Firewall (UFW)<\/a> by denying incoming connections by default while allowing outgoing traffic:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw default deny incoming\nsudo ufw default allow outgoing<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cb43cc&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cb43cc\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/15-set-ufw-default-policies.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal setting the UFW default incoming policy to deny and outgoing policy to allow.\" class=\"wp-image-162239\" style=\"aspect-ratio:4.489208633093525;width:624px;height:auto\" title=\"15-set-ufw-default-policies\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Allow SSH before enabling UFW so you don&rsquo;t lock yourself out. Use the OpenSSH profile when SSH uses its standard port:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw allow OpenSSH<\/pre><p class=\"wp-block-paragraph\">Allow the actual SSH port instead if you&rsquo;ve changed it:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw allow your-ssh-port\/tcp<\/pre><p class=\"wp-block-paragraph\">Add rules only for other services that need public access. A web server, for example, normally needs TCP ports <strong>80<\/strong> for HTTP and <strong>443<\/strong> for HTTPS:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw allow 80\/tcp\nsudo ufw allow 443\/tcp<\/pre><p class=\"wp-block-paragraph\">Skip these rules when the VPS doesn&rsquo;t serve web traffic. Allow only the port and protocol that external users or systems need for every other service.<\/p><p class=\"wp-block-paragraph\">Enable UFW and review the active rules:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw enable\nsudo ufw status verbose<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cb7049&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cb7049\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/16-enable-ufw-and-check-status.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal showing UFW enabled and active with OpenSSH port 22 allowed for IPv4 and IPv6.\" class=\"wp-image-162240\" style=\"aspect-ratio:2.4761904761904763;width:624px;height:auto\" title=\"16-enable-ufw-and-check-status\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Keep your current SSH session open and test a new SSH connection from another terminal before closing it. Test other allowed services as well, such as loading your website after opening ports <strong>80<\/strong> and <strong>443<\/strong>.<\/p><p class=\"wp-block-paragraph\">Remove firewall rules after you stop exposing the service they belong to. List numbered UFW rules first with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw status numbered<\/pre><p class=\"wp-block-paragraph\">Then remove the obsolete rule by replacing <strong>rule-number<\/strong> with its number:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw delete rule-number<\/pre><p class=\"wp-block-paragraph\">Apply the same firewall protection to IPv6 instead of disabling IPv6 by default. Check whether UFW manages IPv6 with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">grep '^IPV6=' \/etc\/default\/ufw<\/pre><p class=\"wp-block-paragraph\">Keep <strong>IPV6=yes<\/strong> when your VPS uses IPv6. UFW then applies the rules you create to both IPv4 and IPv6 traffic.<\/p><p class=\"wp-block-paragraph\">For more advanced rule control on Ubuntu or Debian, use <a data-click-id=\"hgr-post-content-link-iptables\" href=\"\/ng\/tutorials\/iptables-tutorial\/\">iptables<\/a> when you need features such as custom rule ordering or port forwarding.<\/p><p class=\"wp-block-paragraph\">On RHEL-family distros, use <strong>firewalld<\/strong> for typical host firewall rules or <strong>nftables<\/strong> for more advanced configurations.<\/p><p class=\"wp-block-paragraph\">Avoid managing the same host firewall through multiple tools at once because overlapping UFW, <strong>firewalld<\/strong>, <strong>nftables<\/strong>, or manual <strong>iptables<\/strong> rules make the active policy harder to understand and troubleshoot.<\/p><p class=\"wp-block-paragraph\">The Hostinger VPS firewall filters incoming traffic before it reaches your VPS. It isn&rsquo;t active until you create a firewall configuration and activate it for your server.<\/p><p class=\"wp-block-paragraph\">Open <strong>VPS &rarr; Manage &rarr; Security &rarr; Firewall<\/strong>, create a firewall group, and add an accept rule for SSH before activating it.<\/p><p class=\"wp-block-paragraph\">Add accept rules for the other public services you identified earlier. For example, a web VPS using SSH on port <strong>22<\/strong> typically allows TCP ports <strong>22<\/strong>, <strong>80<\/strong>, and <strong>443<\/strong>.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cba427&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cba427\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/17-configure-hostinger-vps-firewall.png\/w=1024,h=1024,fit=scale-down\" alt=\"Hostinger VPS Firewall Configuration page showing an accept rule for TCP port 22 and a default drop rule for other incoming traffic.\" class=\"wp-image-162241\" style=\"aspect-ratio:1.278688524590164;width:624px;height:auto\" title=\"17-configure-hostinger-vps-firewall\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Watch this video if you prefer a visual walkthrough of how to set up a firewall in the Hostinger dashboard:<\/p><figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"How to Secure Your VPS with a Managed Firewall\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/3ro0Wp6gXlM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n  <div class=\"youtube-shortcode\">\n    <div class=\"row\">\n      <div class=\"col-7 col-sm-8 d-flex align-items-center\">\n        <img decoding=\"async\" class=\"channel-logo\" src=\"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/youtube-channels\/hostinger-academy.jpg\" alt=\"youtube channel logo\">\n        <div class=\"d-flex flex-column justify-content-between\">\n          <span class=\"slogan d-none d-sm-block\">Subscribe For more educational videos!<\/span>\n          <span class=\"channel-name\">Hostinger Academy<\/span>\n        <\/div>\n      <\/div>\n      <div class=\"col-5 col-sm-4 d-flex align-items-center justify-content-end\">\n          <a data-click-id=\"hgr-post-content-link-subscribe\" class=\"subscribe-button\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"http:\/\/www.youtube.com\/channel\/UCbNIC-svDbtUOH2qsLnPQPg?sub_confirmation=1\">\n            <img decoding=\"async\" src=\"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/icons\/youtube.svg\" alt=\"subscribe\">\n            <span>Subscribe<\/span>\n          <\/a>\n      <\/div>\n    <\/div>\n  <\/div>\n\n    \n\n\n\n<\/p><p class=\"wp-block-paragraph\">The firewall drops incoming traffic that doesn&rsquo;t match an accept rule, so add the SSH rule before activation to avoid blocking remote access. After you add, change, or remove a rule later, sync the firewall so the updated configuration applies to your VPS.<\/p><p class=\"wp-block-paragraph\">Check both firewall layers when you combine the Hostinger firewall with UFW. SSH will still fail if UFW allows port <strong>22<\/strong> but the Hostinger firewall blocks it, while HTTPS will fail if the Hostinger firewall allows port <strong>443<\/strong> but UFW blocks it.<\/p><p class=\"wp-block-paragraph\">Use Hostinger Agent to inspect the firewall configuration when a required connection stops working after a rule change. Compare the rules for the affected port before adding new exceptions.<\/p><div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg aria-hidden=\"true\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Expert tip\n                <\/p>\n            <\/div>\n            <p class=\"protip__content\">Using Docker? Published container ports can remain reachable from the internet even when UFW blocks them because Docker manages its own firewall rules. Keep an internal service private by binding its published port to localhost, for example <strong>127.0.0.1:8080:80<\/strong> instead of <strong>8080:80<\/strong> in your <a data-click-id=\"hgr-post-content-link-docker-compose-file\" href=\"\/ng\/tutorials\/what-is-docker-compose\/\">Docker Compose file<\/a>, and use the Hostinger VPS firewall to control which public ports remain reachable.<\/p>\n                <div class=\"protip__expert\">\n                    <div class=\"protip__expert-image\">\n                        <img loading=\"lazy\" decoding=\"async\" width=\"48\" height=\"48\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/07\/minijus-savickas.jpg\/w=65,h=65,fit=scale-down\" alt=\"Editor\" \/>\n                    <\/div>\n                    <div>\n                        <p class=\"protip__expert-name\">Minijus Savickas<\/p>\n                        <p class=\"protip__expert-position\">VPS Product Manager<\/p>\n                    <\/div>\n                <\/div>\n        <\/div>\n\n\n\n<\/p><h2 id=\"h-6-restrict-publicly-accessible-services\" class=\"wp-block-heading h-t-title-2\">6. Restrict publicly accessible services<\/h2><p class=\"wp-block-paragraph\">To restrict publicly accessible services, make databases, caches, admin panels, development tools, and other internal services listen only on localhost or a private network unless they genuinely need public access.<\/p><p class=\"wp-block-paragraph\">Check which TCP services are listening for connections:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ss -tlnp<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cbd803&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cbd803\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/18-check-publicly-listening-services.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal output of ss -tlnp showing SSH listening on all IPv4 and IPv6 addresses while resolver services listen only locally.\" class=\"wp-image-162242\" style=\"aspect-ratio:6.24;width:624px;height:auto\" title=\"18-check-publicly-listening-services\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Use the <strong>Local Address<\/strong> and process information to find databases, caches, admin tools, and other internal services that are listening publicly. Focus on services that don&rsquo;t need connections directly from the internet.<\/p><p class=\"wp-block-paragraph\">To keep an internal service off the public internet, change the address it listens on to <strong>127.0.0.1<\/strong>, <strong>::1<\/strong>, or a private IP. For example, make a database listen on <strong>127.0.0.1<\/strong> when only an app on the same VPS connects to it.<\/p><p class=\"wp-block-paragraph\"><a data-click-id=\"hgr-post-content-link-secure-the-publicly-accessible-service\" href=\"\/support\/securing-publicly-accessible-services-on-your-vps\/\">Secure the publicly accessible service<\/a> instead of restricting it to a private IP when it must remain reachable from the internet.<\/p><p class=\"wp-block-paragraph\">Use a private IP instead when another server on the same private network needs access. Configure the listening address with <strong>bind-address<\/strong> for MySQL, <strong>listen_addresses<\/strong> for PostgreSQL, <strong>bind<\/strong> for Redis, or <strong>net.bindIp<\/strong> for MongoDB.<\/p><p class=\"wp-block-paragraph\">Restart the affected service after changing its configuration, then run <strong>sudo ss -tlnp<\/strong> again to confirm that it listens only on the intended address.<\/p><p class=\"wp-block-paragraph\">Disable services you no longer use so they stop running and don&rsquo;t start again after a reboot. Replace <strong>service-name<\/strong> with the actual service name:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl disable --now service-name<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cc098c&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cc098c\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/19-disable-unused-atd-service-ubuntu.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal disabling the unused atd service with systemctl disable --now.\" class=\"wp-image-162243\" style=\"aspect-ratio:17.333333333333332;width:624px;height:auto\" title=\"19-disable-unused-atd-service-ubuntu\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Remove unused software after confirming that your site or app doesn&rsquo;t depend on it. On Debian and Ubuntu, use:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt remove package-name<\/pre><p class=\"wp-block-paragraph\">On RHEL-family distros, use:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf remove package-name<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cc3b0f&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cc3b0f\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/20-remove-unused-at-package-almalinux.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal removing the unused at package with DNF and showing the completed transaction.\" class=\"wp-image-162244\" style=\"aspect-ratio:2.4092664092664093;width:624px;height:auto\" title=\"20-remove-unused-at-package-almalinux\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Remove old test dashboards, development servers, database engines, and other tools after you stop using them.<\/p><p class=\"wp-block-paragraph\">Use an SSH tunnel when you need occasional remote access to a service that should remain on localhost. For a service listening on <strong>127.0.0.1:8080<\/strong>, run this command on your computer:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh -L 8080:127.0.0.1:8080 your-username@your-vps-ip<\/pre><p class=\"wp-block-paragraph\">You can then access the service through <strong>localhost:8080<\/strong> on your computer while the SSH connection remains open, without exposing the service itself to the internet.<\/p><p class=\"wp-block-paragraph\">For other remote-access needs, restrict the service to a trusted source IP when you connect from a fixed public IP, use a private network or VPN for access from trusted devices, or place a browser-based admin tool behind an authenticated HTTPS reverse proxy.<\/p><p class=\"wp-block-paragraph\">Choose the option that keeps the service itself off the public internet.<\/p><p class=\"wp-block-paragraph\">Encrypt connections for services that must remain publicly accessible. Use HTTPS for websites and web interfaces, <a data-click-id=\"hgr-post-content-link-sftp-for-secure-file-transfers\" href=\"\/ng\/tutorials\/how-to-use-sftp-to-safely-transfer-files\/\">SFTP for secure file transfers<\/a>, and TLS for remote database connections that cross the public internet.<\/p><p class=\"wp-block-paragraph\">Run <strong>sudo ss -tlnp<\/strong> again after making the changes. Confirm that internal services no longer listen publicly and that the services or remote-access methods you intentionally kept still work.<\/p><h2 id=\"h-7-protect-app-credentials-and-file-permissions\" class=\"wp-block-heading h-t-title-2\">7. Protect app credentials and file permissions<\/h2><p class=\"wp-block-paragraph\">Protect app credentials and file permissions by keeping secrets out of source code, locking down files that contain them, and running apps with only the access they need.<\/p><p class=\"wp-block-paragraph\">API keys, database passwords, access tokens, private keys, and similar credentials shouldn&rsquo;t appear directly in your app&rsquo;s source code. Store them in <a data-click-id=\"hgr-post-content-link-linux-environment-variables\" href=\"\/ng\/tutorials\/linux-environment-variables\/\">Linux environment variables<\/a>, a protected <strong>.env<\/strong> or configuration file, or a secret-storage tool your app supports.<\/p><p class=\"wp-block-paragraph\">A <strong>.env<\/strong> file stores values such as database passwords and API keys separately from your source code. Keep it and other files containing secrets outside directories that visitors can access through your web server.<\/p><p class=\"wp-block-paragraph\">Keep secret files out of source repositories as well, since committing them can expose credentials to anyone who can access the repository or its history. For Git projects, add <strong>.env<\/strong> to <strong>.gitignore<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.env<\/pre><p class=\"wp-block-paragraph\">Check whether Git already tracks the file:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">git ls-files .env<\/pre><p class=\"wp-block-paragraph\">Remove it from Git tracking without deleting your local copy if the command returns <strong>.env<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">git rm --cached .env<\/pre><p class=\"wp-block-paragraph\">Removing the file from Git doesn&rsquo;t make an exposed credential safe again, because it stays in the repository&rsquo;s history.<\/p><p class=\"wp-block-paragraph\">Replace any password, API key, access token, or private key that you&rsquo;ve already committed to Git, uploaded, or shared, then update the app to use the replacement and disable the old credential.<\/p><p class=\"wp-block-paragraph\">Use different credentials for separate apps and services. For example, give an app its own database user with access only to the database it needs instead of using a database administrator account.<\/p><p class=\"wp-block-paragraph\">Next, restrict access to files that contain secrets. Replace <strong>\/path\/to\/app\/.env<\/strong> with the actual path to your app&rsquo;s <strong>.env<\/strong> file, then <a data-click-id=\"hgr-post-content-link-check-the-files-permissions-owner-and-group\" href=\"\/ng\/tutorials\/how-to-change-linux-permissions-and-owners\/\">check the file&rsquo;s permissions, owner, and group<\/a>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -l \/path\/to\/app\/.env<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cc6d03&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cc6d03\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/21-check-env-file-permissions.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal showing the permissions, owner, and group of the .env file in the example application directory.\" class=\"wp-image-162245\" style=\"aspect-ratio:16.864864864864863;width:624px;height:auto\" title=\"21-check-env-file-permissions\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Use <strong>600<\/strong> when only the file owner needs to read and edit it:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod 600 \/path\/to\/app\/.env<\/pre><p class=\"wp-block-paragraph\">Use <strong>640<\/strong> when the owner needs read and write access and the app runs under a group that also needs to read the file:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod 640 \/path\/to\/app\/.env<\/pre><p class=\"wp-block-paragraph\">Set the correct owner and group when necessary:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo chown your-owner:app-group \/path\/to\/app\/.env<\/pre><p class=\"wp-block-paragraph\">Replace <strong>your-owner<\/strong> with the account that manages the file and <strong>app-group<\/strong> with the group allowed to read it.<\/p><p class=\"wp-block-paragraph\">Run <strong>ls -l \/path\/to\/app\/.env<\/strong> again after changing its ownership or permissions. Confirm that only the intended owner and group can access the file.<\/p><p class=\"wp-block-paragraph\">Avoid using <strong>chmod 777<\/strong> to fix permission errors. It gives every local user read, write, and execute access, which is far more access than secret files or most app files need.<\/p><p class=\"wp-block-paragraph\">Limit the permissions of accounts that run your apps as well. Run apps, background workers, and containers as non-root users unless they need root access for a specific task.<\/p><p class=\"wp-block-paragraph\"><a data-click-id=\"hgr-post-content-link-check-which-user-runs-each-process\" href=\"\/ng\/tutorials\/how-to-list-processes-in-linux\/\">Check which user runs each process<\/a> with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ps -eo user,pid,comm<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cc9d69&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cc9d69\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/22-check-linux-process-users.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal output of ps -eo user,pid,comm listing process owners, process IDs, and commands.\" class=\"wp-image-162246\" style=\"aspect-ratio:1.1795841209829867;width:624px;height:auto\" title=\"22-check-linux-process-users\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Find your app or worker in the output and check the <strong>USER<\/strong> column. Change its configuration if it runs as <strong>root<\/strong> without needing full system access.<\/p><p class=\"wp-block-paragraph\">For a systemd service, assign an existing non-root account with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl edit service-name<\/pre><p class=\"wp-block-paragraph\">Add:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[Service]\nUser=app-user\nGroup=app-group<\/pre><p class=\"wp-block-paragraph\">Make sure the account can access only the files and directories the app needs, then restart the service:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl restart service-name<\/pre><p class=\"wp-block-paragraph\">Configure containers to run as a non-root user instead of using <strong>root<\/strong> by default.<\/p><p class=\"wp-block-paragraph\">Use separate service accounts for unrelated apps that shouldn&rsquo;t share access to the same files. Keep these app accounts out of <strong>sudo<\/strong> and <strong>wheel<\/strong> groups unless they specifically need administrative commands.<\/p><h2 id=\"h-8-monitor-server-and-app-logs\" class=\"wp-block-heading h-t-title-2\">8. Monitor server and app logs<\/h2><p class=\"wp-block-paragraph\">Monitor authentication, system, and app logs for activity that doesn&rsquo;t match the users, services, and workload you expect on your VPS.<\/p><p class=\"wp-block-paragraph\">Start by reviewing recent system and service messages using this <a data-click-id=\"hgr-post-content-link-journalctl-command\" href=\"\/ng\/tutorials\/journalctl-command\/\">journalctl command<\/a>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo journalctl --since today<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169ccceba&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169ccceba\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/23-review-system-logs-journalctl.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal showing recent system and kernel log entries from journalctl --since today.\" class=\"wp-image-162247\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Check SSH logs separately to review login activity. On Debian and Ubuntu, use the <strong>ssh<\/strong> service unit:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo journalctl -u ssh --since today<\/pre><p class=\"wp-block-paragraph\">On RHEL-family distros, use the <strong>sshd<\/strong> service unit:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo journalctl -u sshd --since today<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169ccfc65&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169ccfc65\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/24-review-sshd-logs-almalinux.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal showing SSH service logs with sshd startup events, public-key logins, and connection activity.\" class=\"wp-image-162248\" style=\"aspect-ratio:1.8851963746223566;width:624px;height:auto\" title=\"24-review-sshd-logs-almalinux\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Check <strong>sudo<\/strong> activity to review administrative commands:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo journalctl _COMM=sudo --since today<\/pre><p class=\"wp-block-paragraph\">Next, review logs for the services that run your site or app. Replace <strong>service-name<\/strong> with the service you want to inspect:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo journalctl -u service-name --since today<\/pre><p class=\"wp-block-paragraph\">Web servers also keep their own access and error logs. NGINX commonly uses <strong>\/var\/log\/nginx\/access.log<\/strong> and <strong>\/var\/log\/nginx\/error.log<\/strong>, while Apache commonly uses <strong>\/var\/log\/apache2\/<\/strong> on Debian and Ubuntu or <strong>\/var\/log\/httpd\/<\/strong> on RHEL-family distros.<\/p><p class=\"wp-block-paragraph\">Check your app and database logs too. Their locations depend on how you installed and configured them, so use the log path each service uses.<\/p><p class=\"wp-block-paragraph\">To check whether your VPS may have been compromised, review its logs and current activity for:<\/p><ul class=\"wp-block-list\">\n<li>Repeated failed logins or successful logins you don&rsquo;t recognize.<\/li>\n\n\n\n<li>Unexpected <strong>sudo<\/strong> activity.<\/li>\n\n\n\n<li>Administrator activity followed by new user accounts or SSH keys you didn&rsquo;t add.<\/li>\n\n\n\n<li>New services or listening ports you don&rsquo;t recognize.<\/li>\n\n\n\n<li>App, web server, or database errors that suddenly appear or repeat.<\/li>\n\n\n\n<li>Suspicious outbound connections.<\/li>\n\n\n\n<li>Unexpected CPU, memory, disk, or network usage that appears alongside other suspicious activity.<\/li>\n<\/ul><p class=\"wp-block-paragraph\">Compare events by time instead of treating every warning as a separate problem. An unfamiliar login followed by unexpected <strong>sudo<\/strong> activity and new app errors is more concerning than one failed login attempt.<\/p><p class=\"wp-block-paragraph\">Set alerts for problems that need quick attention, such as a service stopping, disk space running low, or unusual resource usage, when your monitoring tool supports them. Check logs from the same time as the alert to find the cause.<\/p><p class=\"wp-block-paragraph\">Keep file-based logs from growing indefinitely and filling the VPS disk. Check which logs <strong>logrotate<\/strong> already manages without changing anything:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo logrotate --debug \/etc\/logrotate.conf<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cd2fae&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cd2fae\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/25-check-logrotate-configuration.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal showing logrotate debug output for UFW and unattended-upgrades logs, including their rotation schedules.\" class=\"wp-image-162249\" style=\"aspect-ratio:2.319702602230483;width:624px;height:auto\" title=\"25-check-logrotate-configuration\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Confirm that important web server and app log paths appear in the output. Add a rotation rule under <strong>\/etc\/logrotate.d\/<\/strong> for a custom app log that <strong>logrotate<\/strong> doesn&rsquo;t already manage, unless the app handles rotation itself.<\/p><p class=\"wp-block-paragraph\">On Hostinger VPS, Hostinger Agent can inspect logs from the web console while you troubleshoot. For example, ask it to review recent SSH failures or errors from a specific service instead of searching through multiple logs manually.<\/p><p class=\"wp-block-paragraph\">Use centralized logging when you manage several VPSs or need an independent copy of important logs. A <a data-click-id=\"hgr-post-content-link-loki-grafana-tempo-and-mimir-lgtm-stack\" href=\"\/ng\/tutorials\/how-to-set-up-lgtm-stack\/\">Loki, Grafana, Tempo, and Mimir (LGTM) stack<\/a> is one option for collecting and searching logs from multiple systems.<\/p><p class=\"wp-block-paragraph\">Keep the centralized copy on another server or managed logging service when you want it to remain available after a VPS compromise. This also preserves the logs if someone deletes or overwrites the originals.<\/p><h2 id=\"h-9-scan-for-malware-or-unexpected-files-when-appropriate\" class=\"wp-block-heading h-t-title-2\">9. Scan for malware or unexpected files when appropriate<\/h2><p class=\"wp-block-paragraph\">Scan for malware and unexpected files when your VPS handles public-facing apps, accepts file uploads, or otherwise receives untrusted content.<\/p><p class=\"wp-block-paragraph\">Malware scanning checks files directly for known threats that regular log monitoring doesn&rsquo;t inspect. Reviewing unexpected file changes also helps you investigate a suspected compromise.<\/p><p class=\"wp-block-paragraph\">Investigate files you didn&rsquo;t create, scripts that appear in unexpected directories, or files that changed without an update or deployment. To list files modified within the last 24 hours in an app directory, run:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">find \/path\/to\/app -type f -mtime -1 -print<\/pre><p class=\"wp-block-paragraph\">Replace <strong>\/path\/to\/app<\/strong> with the directory you want to inspect.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cd5e6b&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cd5e6b\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/26-find-recently-modified-app-files.png\/w=1024,h=1024,fit=scale-down\" alt=\"Ubuntu terminal using find to list application files modified within the last 24 hours, including index.php, .env, and config.php.\" class=\"wp-image-162250\" style=\"aspect-ratio:7.518072289156627;width:624px;height:auto\" title=\"26-find-recently-modified-app-files\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">A recently changed file isn&rsquo;t automatically malicious, so compare unfamiliar changes with updates, deployments, or other activity you expected during the same period.<\/p><p class=\"wp-block-paragraph\">On Hostinger VPS, open <strong>VPS &rarr; Manage &rarr; Security &rarr; Malware Scanner<\/strong> to install and run its <a data-click-id=\"hgr-post-content-link-monarx-powered-malware-scanner\" href=\"\/support\/8450363-hostinger-vps-malware-scanner\/\">Monarx-powered malware scanner<\/a>. Review any files it flags as compromised or malicious before deciding what to remove or replace.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cd8cca&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cd8cca\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/27-hostinger-vps-malware-scanner-results.png\/w=1024,h=1024,fit=scale-down\" alt=\"Hostinger VPS Malware Scanner showing the Monarx scanner active with 22 files scanned and no compromised or malicious files detected.\" class=\"wp-image-162251\" style=\"aspect-ratio:2.4761904761904763;width:624px;height:auto\" title=\"27-hostinger-vps-malware-scanner-results\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">The malware scanner checks files stored on the VPS but doesn&rsquo;t scan database contents. A clean scan doesn&rsquo;t rule out every type of compromise.<\/p><p class=\"wp-block-paragraph\">You can review detections and clean up affected files manually without a paid Monarx license. Automatic malware cleanup is a separate paid feature, though.<\/p><p class=\"wp-block-paragraph\">Alternatively, use an open-source antivirus scanner such as ClamAV. Install it on Debian and Ubuntu with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update\nsudo apt install clamav<\/pre><p class=\"wp-block-paragraph\">On Rocky Linux and AlmaLinux, enable the EPEL repository and install ClamAV:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf install epel-release\nsudo dnf install clamav clamav-freshclam<\/pre><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cdc333&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cdc333\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/28-install-clamav-almalinux.png\/w=1024,h=1024,fit=scale-down\" alt=\"AlmaLinux terminal installing ClamAV and its supporting packages with DNF.\" class=\"wp-image-162252\" style=\"aspect-ratio:2.0594059405940595;width:624px;height:auto\" title=\"28-install-clamav-almalinux\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">On RHEL, enable the matching EPEL repository first, then install the same packages:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo dnf install clamav clamav-freshclam<\/pre><p class=\"wp-block-paragraph\">On RHEL-family distros, update the ClamAV signature database before the first scan:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo freshclam<\/pre><p class=\"wp-block-paragraph\">Wait for the signature update to finish before running <strong>clamscan<\/strong>.<\/p><p class=\"wp-block-paragraph\">Scan the file or directory you want to check after installing ClamAV:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">clamscan --recursive \/path\/to\/suspicious-directory<\/pre><p class=\"wp-block-paragraph\">Replace <strong>\/path\/to\/suspicious-directory<\/strong> with the actual location.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169cdeddf&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169cdeddf\" class=\"aligncenter size-full is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/29-clamscan-scan-summary.png\/public\" alt=\"ClamAV scan summary showing one directory checked, one files scanned, and zero infected files detected.\" class=\"wp-image-162351\" style=\"aspect-ratio:1.664;width:624px;height:auto\" title=\"29-clamscan-scan-summary\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Review detected files before deleting them because scanners sometimes flag legitimate files.<\/p><p class=\"wp-block-paragraph\">Regardless of the scanner you use, malware scanning complements patching, secure authentication, firewall rules, service restrictions, and log monitoring rather than replacing them.<\/p><h2 id=\"h-10-maintain-automated-backups-and-test-restores\" class=\"wp-block-heading h-t-title-2\">10. Maintain automated backups and test restores<\/h2><p class=\"wp-block-paragraph\">Maintain automated VPS backups by keeping recurring backups enabled. Then test restores regularly to confirm that you can restore a working server after file deletion, data corruption, or other server problems.<\/p><p class=\"wp-block-paragraph\">Recurring backups run automatically on a schedule and give you copies from different dates. Choose the backup frequency based on how much recent data you can afford to lose.<\/p><p class=\"wp-block-paragraph\">A frequently changing store, forum, or app usually needs more frequent backups than a mostly static website because more orders, uploads, or database changes occur between backups.<\/p><p class=\"wp-block-paragraph\">A snapshot captures the VPS at one specific moment so you can return to that state if a planned change causes problems. Use snapshots before major updates, migrations, operating system changes, or risky configuration changes.<\/p><p class=\"wp-block-paragraph\">Unlike recurring backups, snapshots don&rsquo;t provide an ongoing history of recovery points. They&rsquo;re better suited to short-term protection around a specific change.<\/p><p class=\"wp-block-paragraph\">On Hostinger VPS, manage <a data-click-id=\"hgr-post-content-link-vps-backups-and-snapshots\" href=\"\/support\/1583232-how-to-back-up-or-restore-a-vps-at-hostinger\/\">VPS backups and snapshots<\/a> from <strong>VPS &rarr; Manage &rarr; Backups &amp; Monitoring &rarr; Snapshots &amp; Backups<\/strong>.<\/p><div class=\"wp-block-image\"><figure data-wp-context=\"{&quot;imageId&quot;:&quot;6b0c169ce1eb6&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6b0c169ce1eb6\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2026\/11\/30-hostinger-vps-backups-snapshots.png\/w=1024,h=1024,fit=scale-down\" alt=\"Hostinger Snapshots &amp; Backups page showing a weekly backup schedule, an option to upgrade to daily backups, and an existing VPS snapshot with a restore option.\" class=\"wp-image-162254\" style=\"aspect-ratio:1.3654266958424508;width:624px;height:auto\" title=\"30-hostinger-vps-backups-snapshots\"><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p class=\"wp-block-paragraph\">Hostinger enables weekly automated backups by default. You can upgrade to daily backups if you need more frequent recovery.<\/p><p class=\"wp-block-paragraph\">Hostinger stores automated backups separately from your VPS. It stores only one snapshot at a time on the VPS server and deletes it automatically after one day.<\/p><p class=\"wp-block-paragraph\">Keep another copy of critical data on a different server or storage service when you need a backup independent of your VPS provider&rsquo;s backup system.<\/p><p class=\"wp-block-paragraph\">For example, <a data-click-id=\"hgr-post-content-link-use-rsync\" href=\"\/ng\/tutorials\/how-to-use-rsync\/\">use rsync<\/a> to copy critical files to another Linux server, including database exports, uploaded files, or other app data that would be difficult to recreate.<\/p><p class=\"wp-block-paragraph\">Use app-level backups when you need to restore one component without rolling back the entire VPS. A separate database backup, for example, lets you recover database data without replacing the rest of the server.<\/p><p class=\"wp-block-paragraph\">Test restores in a separate environment whenever possible so you don&rsquo;t disrupt the live VPS. Restore the backup there, then check whether the recovered workload works.<\/p><p class=\"wp-block-paragraph\">Verify the following after restoring:<\/p><ul class=\"wp-block-list\">\n<li>Required files and directories are present.<\/li>\n\n\n\n<li>Databases restore correctly and contain the expected data.<\/li>\n\n\n\n<li>Apps and supporting services start successfully.<\/li>\n\n\n\n<li>Required configuration files are available.<\/li>\n\n\n\n<li>File ownership and permissions are correct.<\/li>\n\n\n\n<li>You can restore required passwords, API keys, certificates, and other secrets securely.<\/li>\n\n\n\n<li>The restored site, app, database connections, background jobs, and other important functions work as expected.<\/li>\n<\/ul><p class=\"wp-block-paragraph\">Fix anything the restore test shows is missing. For example, add database backups to your backup process and test again if the files restore correctly but the database doesn&rsquo;t.<\/p><p class=\"wp-block-paragraph\">Write down the restore order for apps that depend on several components. For example, you may need to restore the files first, then the database, configuration, and secrets, and finally start the required services.<\/p><h2 id=\"h-how-do-you-maintain-vps-security-over-time\" class=\"wp-block-heading h-t-title-2\">How do you maintain VPS security over time?<\/h2><p class=\"wp-block-paragraph\">To maintain your VPS security over time, turn the initial hardening into a routine you repeat on a schedule and after security-related changes.<\/p><p class=\"wp-block-paragraph\">Start by writing down what your normal VPS setup should look like. Note who should have administrator access, which ports and services should be public, which apps require regular updates, which logs you rely on, and what your backups cover.<\/p><p class=\"wp-block-paragraph\">Use that record during future reviews to spot anything that changed unexpectedly or no longer matches how you use the server.<\/p><p class=\"wp-block-paragraph\">Start with a monthly review. Move to weekly reviews for a VPS with frequent deployments, user changes, configuration changes, or new public services.<\/p><p class=\"wp-block-paragraph\">Each scheduled review covers five checks: pending updates, user accounts and SSH keys, listening ports and firewall rules, recent log activity, and the latest successful backup.<\/p><p class=\"wp-block-paragraph\">You don&#8217;t need to repeat every hardening check after every change. Focus only on the security checks affected by what changed:<\/p><ul class=\"wp-block-list\">\n<li>Review administrator access after adding or removing an administrator or changing authentication.<\/li>\n\n\n\n<li>Review firewall rules and listening services after opening a port or deploying a service that accepts network connections.<\/li>\n\n\n\n<li>Review credentials, permissions, logs, and backups after deploying or migrating an app.<\/li>\n\n\n\n<li>Review affected services and their configuration after a major OS or app upgrade.<\/li>\n<\/ul><p class=\"wp-block-paragraph\">Run the relevant checks immediately after these changes instead of waiting for the next scheduled review.<\/p><p class=\"wp-block-paragraph\">Keep a short record of important security-related changes. Note what changed, who changed it, when it happened, and which checks you ran afterward so you can trace unexpected settings later.<\/p><p class=\"wp-block-paragraph\">VPS hardening secures the server itself, but each app you install brings its own security requirements. Keep a separate checklist for each web server, CMS, database, container, control panel, or other app and include the security settings and maintenance that software requires.<\/p><p class=\"wp-block-paragraph\">Update your maintenance notes as the VPS changes. Remove checks for software you no longer use, add checks for new services, and keep the routine matched to what runs on the server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To secure your Linux virtual private server (VPS), protect administrative access and keep the operating system and software patched. Then limit unnecessary internet exposure and maintain backups you can restore. VPS security means protecting your server, the software you run on it, and its data from unauthorized access, exploitation, malware, and data loss. On a [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/vps-security\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":155397,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"VPS security tips to protect your Linux server","rank_math_description":"Improve VPS security by hardening SSH access, patching software, limiting exposed services, protecting secrets, monitoring activity, and maintaining backups.","rank_math_focus_keyword":"vps security","_content_updated_date":"2026-11-20","footnotes":""},"categories":[22670],"tags":[],"class_list":["post-53874","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/vps-security\/","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/vps-seguro","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/securite-vps","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/seguridad-vps","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-mengamankan-vps","default":0},{"locale":"de-DE","link":"https:\/\/www.hostinger.com\/de\/tutorials\/tipps-zur-vps-sicherheit","default":0},{"locale":"it-IT","link":"https:\/\/www.hostinger.com\/it\/tutorial\/sicurezza-vps","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/vps-security\/","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/vps-security\/","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/vps-security\/","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/vps-security\/","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/vps-security\/","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/vps-security\/","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/vps-security\/","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/seguridad-vps","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/seguridad-vps","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/seguridad-vps","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/vps-seguro","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/53874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=53874"}],"version-history":[{"count":56,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/53874\/revisions"}],"predecessor-version":[{"id":155440,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/53874\/revisions\/155440"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media\/155397"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=53874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=53874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=53874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}