{"id":36262,"date":"2022-06-29T14:14:38","date_gmt":"2022-06-29T06:14:38","guid":{"rendered":"https:\/\/www.casbay.com\/blog\/?p=36262"},"modified":"2022-09-22T17:14:34","modified_gmt":"2022-09-22T09:14:34","slug":"15-security-tips-for-linux-vps-hosting","status":"publish","type":"post","link":"https:\/\/www.casbay.com\/blog\/vps-hosting\/15-security-tips-for-linux-vps-hosting","title":{"rendered":"15 Security Tips for Linux VPS Hosting"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"36262\" class=\"elementor elementor-36262\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-0876511 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"0876511\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-97c9a24\" data-id=\"97c9a24\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-776760b elementor-widget elementor-widget-image\" data-id=\"776760b\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.casbay.com\/blog\/wp-content\/uploads\/2022\/06\/15-Security-Tips-for-Linux-VPS-Hosting--1024x576.png\" class=\"attachment-large size-large wp-image-36263\" alt=\"security linux vps\" srcset=\"https:\/\/www.casbay.com\/blog\/wp-content\/uploads\/2022\/06\/15-Security-Tips-for-Linux-VPS-Hosting--1024x576.png 1024w, https:\/\/www.casbay.com\/blog\/wp-content\/uploads\/2022\/06\/15-Security-Tips-for-Linux-VPS-Hosting--300x169.png 300w, https:\/\/www.casbay.com\/blog\/wp-content\/uploads\/2022\/06\/15-Security-Tips-for-Linux-VPS-Hosting--768x432.png 768w, https:\/\/www.casbay.com\/blog\/wp-content\/uploads\/2022\/06\/15-Security-Tips-for-Linux-VPS-Hosting-.png 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e9a4ac5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e9a4ac5\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d45491f\" data-id=\"d45491f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f61727c elementor-widget elementor-widget-text-editor\" data-id=\"f61727c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h2>Can Linux VPS Be Hacked? Is it Secure?\u00a0<\/h2><p>Yes, VPS\u00a0may well be\u00a0hacked. Given enough time and dedication, any server\u00a0may be\u00a0hacked, including virtual machines, even with security controls\u00a0in situ. No system is ever 100% risk-free, but administrators can reduce risk to\u00a0all-time low\u00a0possible level to avoid threats and stop attacks. The Linux\u00a0software package\u00a0is usually\u00a0secure, but vulnerabilities are introduced when users misconfigure the system, add vulnerable software, leave applications unpatched, or download and install malware locally.\u00a0because the\u00a0system changes,\u00a0the chance\u00a0also increases or decreases\u00a0looking on\u00a0what was changed.<\/p><p>Sophisticated malware can affect over\u00a0just the local machine. It can sometimes traverse the network from the hosted server, and it can occasionally affect other systems. If any sensitive data is stored on the local server,\u00a0it might\u00a0be exposed\u00a0and therefore the\u00a0host\u00a0may well be\u00a0the victim of\u00a0an information\u00a0breach. Even without traversing the network, malware affects the local virtual machine instance.<br \/><br \/>The virtual machine instance hosts the customer\u2019s website, so\u00a0whether or not\u00a0malware\u00a0doesn&#8217;t\u00a0affect other customers on the server, it does affect the local instance\u2019s hosted applications. Should a customer keep sensitive information on the server, it\u00a0may be\u00a0disclosed to attackers if the hosted site\u00a0isn&#8217;t\u00a0secure.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2551e56 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2551e56\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8435c3f\" data-id=\"8435c3f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3660e5d elementor-widget elementor-widget-text-editor\" data-id=\"3660e5d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h2>How to Secure a VPS?<\/h2><p>There are several steps to secure VPS hosting. While hosting providers rely somewhat on the customers protecting their site, administrators can still configure and install software that will better secure a VPS. Customers hosting their sites on VPS can also take steps to secure their sites and services.\u00a0<\/p><p><strong>1.Choose a Hosting Provider That Takes Security Seriously<\/strong><\/p><p>Customers rely on web hosts to keep infrastructure secure. Not every web hosting provider treats security equally. To keep a website secure, customers should choose their web host wisely. For example, Interserver.net has proven to focus on security of their customer sites.\u00a0<a href=\"https:\/\/www.interserver.net\/\" target=\"_blank\" rel=\"nofollow noopener\" class=\"broken_link\">Interserver.net<\/a>\u00a0is a US-based hosting service with a good reputation for quality service at an affordable price. They have two datacenters on the east and west coast of the US to service their thousands of customers ranging from small individual site owners to Fortune 500s.<\/p><p><strong>2.Change the SSH Default Port<\/strong><\/p><p>SSH is necessary for remote access to a server, and it\u2019s installed with the default port 22. Attackers scan servers for open ports such as 22 to gain remote access to SSH. After detecting SSH on port 22, an attacker might launch a brute-force attack to obtain remote access to the server by guessing the root user\u2019s credentials.<\/p><p>To combat this attack, the SSH port can be moved to an alternative one. When SSH runs on an alternative port, any automated scans will show nothing for port 22. To change the port, the following file must be updated (we\u2019ll change this file in other tips, so keep this file open):<\/p><p>\/etc\/ssh\/sshd_config<\/p><p>Before you edit the file, make sure that the port is not used by another service, or you will have a conflict and both services will not run properly.<\/p><p><strong>3.Monitor Server Logs<\/strong><\/p><p>Both host administrators and website owners should have monitoring enabled. Monitoring servers requires logging specific events such as authentication failures (and possibly successes), failed uploads, errors, and other common threats. These logs can then be used in analysis and reports that can give administrators detailed information and insights into activity happening on the server. Logs can tell administrators of an ongoing attack or a compromise.<\/p><p>Host administrators can monitor activity on their servers to ensure that customer sites are secure, but website owners should also monitor their own sites. The sooner a compromise is contained, the smaller the window of opportunity for an attacker to exfiltrate data.<\/p><p><strong>4.Disable Unused Ports<\/strong><\/p><p>Linux installs with several ports open. Some are necessary for certain applications, and others are unnecessary. For example, port 80 is often opened for web applications, but it\u2019s possible that you will not need this port open. Leaving unused ports open increases the server\u2019s attack surface, so best practices suggest that they should be disabled.<\/p><p>You can identify open ports using the netstat command. You can then use firewall settings or edit open ports using the iptables command. First, use netstat to view open ports:<\/p><p>netstat -a<\/p><p>For example, suppose that you want to drop port 22. Netstat will confirm that port 22 is open. After you confirm, type the following command to drop port 22 and therefore block it from being used:<\/p><p>iptables -I INPUT -p tcp \u2013dport 22 -j DROP<\/p><p><strong>5.Use GnuPG Encryption<\/strong><\/p><p>Any data transferred over the internet is vulnerable to eavesdropping. Websites use HTTPS to encrypt data between customers and websites, but other data could be intercepted &#8211; such as credentials sent to server services or files transferred over FTP. To overcome this issue, asynchronous encryption is used to encrypt data with a public key that can then be decrypted only with the recipient\u2019s private key.<\/p><p>The GnuPG application will let administrators and site owners transfer data using asynchronous encryption. The public key generated can be used by any third-party to send encrypted data to the site owner or administrators, and the private key is used to decrypt it. Because the private key is used to decrypt data, it should be secured and never disclosed to a third party.<\/p><p><strong>6.Implement a Strong Password Policy<\/strong><\/p><p>A password policy is always necessary for any user with access to network resources. Users often use weak passwords that can be easily guessed using brute-force attacks. A password policy enforces length and complexity requirements when any password is generated, including new passwords when users are forced to change them and password resets.<\/p><p>Generally, passwords should:<\/p><ul><li aria-level=\"1\">Contain at least 10 characters, and 12 characters for access to highly sensitive data.<\/li><li aria-level=\"1\">Contain at least 1 numeric character.<\/li><li aria-level=\"1\">Contain at least 1 special character.<\/li><li aria-level=\"1\">Contain uppercase and lowercase letters.<\/li><\/ul><p><strong>7.Use Disk Partitioning<\/strong><\/p><p>Attackers that can run executables on the operating system can tamper with its operations and functions and eavesdrop on data. To gain access to the operating system, an attacker can use the\u00a0\/tmp\u00a0and\u00a0\/var\/tmp\u00a0user directories to upload malicious files and execute them. You can separate the operating system from user file partitions to add security to the server.<\/p><p>To separate the two, you use the noexec (no execution of binaries) and nosuid (do not allow set-user-identifier or set-group-identifier) option to mount the two partitions securely:<\/p><p># mount -t tmpfs -o noexec,nosuid,nodev tmpfs \/tmp\u00a0<\/p><p># mount -t tmpfs -o noexec,nosuid,nodev tmpfs \/var\/tmp<\/p><p><strong>8.Use SFTP<\/strong><\/p><p>Secure FTP adds encryption to file transfers uploaded to the server. All data transferred over FTP is in cleartext, but SFTP is \u201cFTP over SSH,\u201d adding encryption to file transfers. Some site owners might be tempted to use FTPS, but FTPS only encrypts credentials sent to authenticated into the server. SFTP encrypts both credentials and the files being transferred.<\/p><p><strong>9.Keep the Operating System Patched and Updated<\/strong><\/p><p>The Linux operating system was created with security in mind, but occasionally issues are found that must be patched. When patches are necessary, the vendor for your distribution will release an update. In some cases, the vulnerability discovered is considered critical. When the vulnerability is critical, it\u2019s important that administrators update the operating system immediately because the exploit could open the server to a compromise.<\/p><p>The longer the operating system is left unpatched, the longer the window of opportunity for attackers will remain open. Administrators will often set aside a set schedule for server updates, but delayed updates leave the server open to exploits until patches are installed.<\/p><p><strong>10.Prevent Anonymous FTP Uploads<\/strong><\/p><p>If you allow anonymous FTP uploads to your Linux server, it\u2019s highly likely that your server will become a silo for illegal software or other inappropriate content. It could host malware that could later affect the rest of the virtual machine. Instead of leaving the FTP server open to anonymous uploads, it should be disabled so that only approved users can upload to FTP.<\/p><p>To disable anonymous access, open the following file:<\/p><p>\/etc\/vsftpd\/vsftpd.conf<\/p><p>Edit the anonymous access configuration by changing it to the following:<\/p><p>anonymous_enabled=NO<\/p><p><strong>11.Install a Rootkit Scanner<\/strong><\/p><p>Rootkits are one of the most dangerous malware applications. They could give the attacker control over the server, run other malware on the operating system, or disable any antivirus applications. To stop rootkits or detect them should they compromise the server, a rootkit scanner such as chrootkit can be installed to stop them.<\/p><p>Removing rootkits is much more difficult than standard malware, because it integrates with the operating system and can go undetected by standard anti-malware services. For sophisticated rootkits, it might be necessary to reinstall the operating system. For this reason, it\u2019s important to use anti-malware applications that detect and stop them.<\/p><p><strong>12.Disable root Logins<\/strong><\/p><p>Every VPS is created with the root account, which contains the highest level of privileges on the system. Hackers know that many administrators leave root enabled and use the account to configure the server. In the interest of security, the root account should be disabled and another user account created with root privileges. This strategy secures the server from brute-force attacks against the root account.<\/p><p>Before disabling root, create a user account with elevated privileges, then open the following file:<\/p><p>\/etc\/ssh\/sshd_config<\/p><p>Change the root login parameter to the following:<\/p><p>PermitRootLogin=no<\/p><p>Please restart the sshd service after making this change.<\/p><p><strong>13.Keep Software Updated<\/strong><\/p><p>You know that the operating system should stay updated, but don\u2019t forget the other software running on the server. Common vulnerabilities are logged in the\u00a0<a href=\"https:\/\/cve.mitre.org\/\" target=\"_blank\" rel=\"nofollow noopener\">CVE database<\/a>, but you must stay aware of the latest updates and patches addressing security issues involving the software installed on the system.<\/p><p>Software vendors release updates and identify the bugs and vulnerabilities addressed for each patch. You could manually update software and check for updates every day, or you can let\u00a0<a href=\"https:\/\/www.imunify360.com\/imunify360\" target=\"_blank\" rel=\"noopener\">Imunify360<\/a>\u00a0automatically update and patch software so that it\u2019s done for you. By keeping software updated in a timely manner, it reduces the opportunity for attackers to exploit a common vulnerability.<\/p><p><strong>14.Always Create and Safely Store Backups<\/strong><\/p><p>Backups are essential should your system be compromised beyond repair or any data is corrupted and must be restored. For example, if the operating system suffers from a rootkit compromise, instead of reinstalling the operating system, you can restore from a backup. With a VPS, you can back up the entire VPS instance and restore it should you need to.<\/p><p>You should keep backups secure and have a retention plan to keep backup files for a specific amount of time before you delete or archive them. At least one backup should be offsite in case the host experiences any downtime.<\/p><p><strong>15.Install Full Server Protection<\/strong><\/p><p>Securing a server and continuously monitoring it can take a big portion of your day, which is why many business owners hosting on VPS do not have the time to properly maintain server software and resources. Instead of spending time reviewing multiple reports, scanning servers manually, and removing any malware, allow\u00a0<a href=\"https:\/\/www.imunify360.com\/imunify360\" rel=\"noopener\">Imunify360<\/a>\u00a0with\u00a0<a href=\"https:\/\/www.imunify360.com\/getting-started-malware-scanning\/\" target=\"_blank\" rel=\"noopener\">Linux malware scanner<\/a>\u00a0and\u00a0<a href=\"https:\/\/www.imunify360.com\/getting-started-proactive-defense\/\" target=\"_blank\" rel=\"noopener\">Proactive Defense<\/a>\u00a0to monitor and remove malware for you.<\/p><p>While this list is not exhaustive, it starts VPS administrators off on the right path towards securing their server. Losing data and time costs thousands of dollars in lost revenue and brand reputation damage. With Imunify360 and the right server configurations, any site hosted on a VPS will be more secure, monitored for any strange activity, and in many cases automatically cleaned without any administrator hassles.<\/p><p>Take your web hosting security to the next level with Imunify360 security suite.\u00a0<a href=\"https:\/\/www.imunify360.com\/the-imunify360-difference\/\" target=\"_blank\" rel=\"noopener\">Imunify360<\/a>\u00a0is a complete security suite with all components working together to keep your servers safe and running while you could focus on other business tasks. Imunify360 is a synergy of Antivirus, Firewall, WAF, PHP Security Layer, Patch Management, Domain Reputation with easy UI and advanced automation. Try Imunify360 free for 14 days and see results in just one week.<\/p><p>\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-d40f0fc elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"d40f0fc\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0289262\" data-id=\"0289262\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f27f226 elementor-widget elementor-widget-text-editor\" data-id=\"f27f226\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><a href=\"https:\/\/www.casbay.com\/\" target=\"_blank\" rel=\"noopener\">make your server secure now<\/a><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Can Linux VPS Be Hacked? Is it Secure? Yes, VPS\u00a0may well be\u00a0hacked. Given enough time and dedication, any server\u00a0may be\u00a0hacked, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":"","_wpscppro_custom_social_share_image":0},"categories":[94],"tags":[102],"_links":{"self":[{"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/posts\/36262"}],"collection":[{"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/comments?post=36262"}],"version-history":[{"count":4,"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/posts\/36262\/revisions"}],"predecessor-version":[{"id":36310,"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/posts\/36262\/revisions\/36310"}],"wp:attachment":[{"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/media?parent=36262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/categories?post=36262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.casbay.com\/blog\/wp-json\/wp\/v2\/tags?post=36262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}