{"id":2969,"date":"2024-06-12T10:19:24","date_gmt":"2024-06-12T04:49:24","guid":{"rendered":"https:\/\/www.nettigritty.com\/kb\/?p=2969"},"modified":"2024-06-12T10:20:06","modified_gmt":"2024-06-12T04:50:06","slug":"how-to-install-and-use-csf","status":"publish","type":"post","link":"https:\/\/www.nettigritty.com\/kb\/cpanel\/how-to-install-and-use-csf\/","title":{"rendered":"How to install and use CSF"},"content":{"rendered":"<p>ConfigServer Security &amp; Firewall (CSF) is a popular and comprehensive security tool for Linux servers. It includes a stateful packet inspection firewall, intrusion detection, and various other security features. Here&#8217;s how to install and configure CSF on a Linux server, typically on a distribution like CentOS, Ubuntu, or Debian.<\/p>\n<h3>Step-by-Step Installation Guide<\/h3>\n<h4>Prerequisites<\/h4>\n<ul>\n<li>Root access to your server<\/li>\n<li>A Linux-based OS (CentOS, Ubuntu, Debian, etc.)<\/li>\n<\/ul>\n<h4>1. Update Your System<\/h4>\n<p>Before installing CSF, ensure your system is up to date.<\/p>\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo apt update &amp;&amp; sudo apt upgrade -y <span class=\"hljs-comment\"># For Debian\/Ubuntu<\/span> <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo yum update -y <span class=\"hljs-comment\"># For CentOS\/RHEL<\/span> <\/code><\/div>\n<\/div>\n<h4>2. Install Required Packages<\/h4>\n<p>Ensure you have the necessary packages installed.<\/p>\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo apt install wget unzip -y <span class=\"hljs-comment\"># For Debian\/Ubuntu<\/span> <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo yum install wget unzip -y <span class=\"hljs-comment\"># For CentOS\/RHEL<\/span> <\/code><\/div>\n<\/div>\n<h4>3. Download and Install CSF<\/h4>\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<pre>cd \/usr\/src\r\nrm -fv csf.tgz\r\nwget https:\/\/download.configserver.com\/csf.tgz\r\ntar -xzf csf.tgz\r\ncd csf\r\nsh install.sh<\/pre>\n<\/div>\n<\/div>\n<h4>4. Test the Installation<\/h4>\n<p>CSF has a script to check if all necessary components are installed:<\/p>\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo perl \/usr\/local\/csf\/bin\/csftest.pl <\/code><\/div>\n<\/div>\n<p>The script will indicate if there are any issues that need to be resolved.<\/p>\n<h4>5. Configure CSF<\/h4>\n<p>CSF comes with a default configuration that you can modify based on your needs.<\/p>\n<ul>\n<li><strong>Edit the main configuration file<\/strong>:\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo nano \/etc\/csf\/csf.conf <\/code><\/div>\n<div dir=\"ltr\"><\/div>\n<\/div>\n<\/li>\n<li><strong>Enable CSF and LFD (Login Failure Daemon)<\/strong>: Change <code>TESTING = \"1\"<\/code> to <code>TESTING = \"0\"<\/code> in the configuration file to enable CSF.<\/li>\n<li><strong>Set your IP addresses<\/strong>: It&#8217;s a good practice to whitelist your IP address to avoid locking yourself out.\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo nano \/etc\/csf\/csf.allow <\/code><\/div>\n<\/div>\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md\">\n<div class=\"flex items-center\"><\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs\">tcp|in|d=22|s=YOUR_IP_ADDRESS <\/code><\/div>\n<\/div>\n<\/li>\n<\/ul>\n<h4>6. Start and Enable CSF<\/h4>\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo systemctl start csf <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo systemctl <span class=\"hljs-built_in\">enable<\/span> csf <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo systemctl start lfd <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo systemctl <span class=\"hljs-built_in\">enable<\/span> lfd <\/code><\/div>\n<\/div>\n<h4>7. Check CSF Status<\/h4>\n<p>You can check the status of CSF and LFD to ensure they are running correctly.<\/p>\n<div class=\"dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo csf -v <span class=\"hljs-comment\"># Verify CSF version<\/span> <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo csf -e <span class=\"hljs-comment\"># Enable CSF<\/span> <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo csf -x <span class=\"hljs-comment\"># Disable CSF (if needed)<\/span> <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo csf -r <span class=\"hljs-comment\"># Restart CSF<\/span> <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo csf -s <span class=\"hljs-comment\"># Start CSF<\/span> <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo systemctl status csf <\/code><\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-sh\">sudo systemctl status lfd <\/code><\/div>\n<\/div>\n<h3>Additional Configuration<\/h3>\n<ul>\n<li><strong>Adding\/Removing Ports<\/strong>: Modify <code>\/etc\/csf\/csf.conf<\/code> to add or remove allowed ports.<\/li>\n<li><strong>Configuring Alerts<\/strong>: Configure email alerts for suspicious activities in <code>\/etc\/csf\/csf.conf<\/code>.<\/li>\n<\/ul>\n<h3>Useful CSF Commands<\/h3>\n<ul>\n<li><code>csf -d IP<\/code> : Deny an IP address<\/li>\n<li><code>csf -a IP<\/code> : Allow an IP address<\/li>\n<li><code>csf -r<\/code> : Restart CSF<\/li>\n<li><code>csf -t<\/code> : Display currently blocked IPs<\/li>\n<\/ul>\n<p>By following these steps, you should have CSF installed and configured on your server. Remember to regularly update CSF and review its logs to maintain a secure environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ConfigServer Security &amp; Firewall (CSF) is a popular and comprehensive security tool for Linux servers. It includes a stateful packet inspection firewall, intrusion detection, and various other security features. Here&#8217;s how to install and configure CSF on a Linux server, typically on a distribution like CentOS, Ubuntu, or Debian. Step-by-Step Installation Guide Prerequisites Root access [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,6],"tags":[],"class_list":["post-2969","post","type-post","status-publish","format-standard","hentry","category-cpanel","category-linux"],"_links":{"self":[{"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/posts\/2969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/comments?post=2969"}],"version-history":[{"count":3,"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/posts\/2969\/revisions"}],"predecessor-version":[{"id":3240,"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/posts\/2969\/revisions\/3240"}],"wp:attachment":[{"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/media?parent=2969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/categories?post=2969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nettigritty.com\/kb\/wp-json\/wp\/v2\/tags?post=2969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}