{"id":42394,"date":"2022-08-29T12:30:03","date_gmt":"2022-08-29T17:30:03","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=42394"},"modified":"2022-12-05T05:21:15","modified_gmt":"2022-12-05T11:21:15","slug":"how-to-install-fail2ban-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/","title":{"rendered":"How to Install Fail2ban on Ubuntu 22.04"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p><img decoding=\"async\" class=\"alignnone size-full wp-image-42748\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp\" alt=\"how to install fail2ban on ubuntu 22.04\" width=\"742\" height=\"372\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp 742w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04-300x150.webp 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04-150x75.webp 150w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/p>\n<p>Fail2ban is an intrusion prevention tool that protects computers from brute force and other attacks by closely monitoring the log files. The tool would then ban the suspicious IP addresses based on the predefined number of failed login attempts to stop the attacks. Fail2Ban uses jails to monitor log files for authentication failures and other entries that can be considered suspicious activities.<\/p>\n<p>It can be configured to send an email and\/or ban the attacker\u2019s IP address for a pre-defined length of time. After the ban period is over, the attacking IP address will be automatically unbanned. In this tutorial, we will show you how to install and <a href=\"https:\/\/www.rosehosting.com\/ubuntu-hosting\/\">configure Fail2ban on Ubuntu 22.04<\/a>.<\/p>\n<p><!--more--><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69ecc6b24a053\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69ecc6b24a053\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Step-1-Login-to-the-server\" >Step 1. Login to the server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Step-2-Install-Fail2ban\" >Step 2. Install Fail2ban<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Step-3-Configure-Fail2ban\" >Step 3. Configure Fail2ban<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Whitelist-IP\" >Whitelist IP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Ban-Time-Set-Up\" >Ban Time Set-Up<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Email-Notifications\" >Email Notifications<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#Fail2ban-Jails\" >Fail2ban Jails<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#BanUnban-an-IP\" >Ban\/Unban an IP<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Ubuntu 22.04<\/li>\n<li>SSH access with root privileges or a regular system user with sudo privileges<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Step-1-Login-to-the-server\"><\/span>Step 1. Login to the server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>First, log in to your Ubuntu 22.04 server through SSH as the root user:<\/p>\n<pre>ssh root@IP_Address -p Port_number<\/pre>\n<p>Replace &#8220;root&#8221; with a user that has sudo privileges if necessary. Additionally, replace &#8220;IP_Address&#8221; and &#8220;Port_Number&#8221; with your server\u2019s respective IP address and SSH port number.<\/p>\n<p>You can check whether you have the proper Ubuntu version installed on your server with the following command:<\/p>\n<pre>$ lsb_release -a<\/pre>\n<p>You should get an output like this:<\/p>\n<pre>No LSB modules are available.\r\nDistributor ID: Ubuntu\r\nDescription: Ubuntu 22.04 LTS\r\nRelease: 22.04\r\nCodename: jammy<\/pre>\n<p>Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date.<br \/>\nYou can do this by running the following commands:<\/p>\n<pre>$ sudo apt update -y\r\n$ sudo apt upgrade -y<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Step-2-Install-Fail2ban\"><\/span>Step 2. Install Fail2ban<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Fail2ban is available in the default Ubuntu repository, so we can simply run the following command to install it.<\/p>\n<pre>$ sudo apt install fail2ban -y<\/pre>\n<p>Then, invoke this command to enable and run fail2ban<\/p>\n<pre>$ sudo systemctl enable --now fail2ban<\/pre>\n<p>Fail2ban is installed and running now, you can verify this by invoking this command:<\/p>\n<pre>$ sudo systemctl status fail2ban<\/pre>\n<p><img decoding=\"async\" class=\"size-full wp-image-42395 alignnone\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban-systemctl-status.jpg\" alt=\"\" width=\"758\" height=\"238\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban-systemctl-status.jpg 758w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban-systemctl-status-300x94.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban-systemctl-status-150x47.jpg 150w\" sizes=\"(max-width: 758px) 100vw, 758px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Step-3-Configure-Fail2ban\"><\/span>Step 3. Configure Fail2ban<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In Ubuntu, you will see the configuration files in \/etc\/fail2ban\/jail.conf and \/etc\/fail2ban\/jail.d\/defaults-debian.conf. Fail2ban will load .local first first before loading .conf files. So, it is necessary to create a copy of the default jail.conf file as jail.local. We will configure everything by modifying the jail.local file. Please also note that modifying the default .conf files is not recommended, as they could be overwritten upon update.<\/p>\n<pre>$ sudo cp \/etc\/fail2ban\/jail.conf \/etc\/fail2ban\/jail.local<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Whitelist-IP\"><\/span>Whitelist IP<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The first thing you need to do is to whitelist your own server, let&#8217;s edit \/etc\/fail2ban\/jail.local, and uncomment the &#8216;ignoreip&#8217; line. You can also add other IP addresses, and they should be separated with a space or comma.<\/p>\n<pre>$ sudo nano \/etc\/fail2ban\/jail.local<\/pre>\n<p>Find the line &#8216;ignoreip&#8217; and uncomment it.<\/p>\n<pre>#ignoreip = 127.0.0.1\/8 ::1<\/pre>\n<p>It should look like this:<\/p>\n<pre>ignoreip = 127.0.0.1\/8 ::1<\/pre>\n<p><img decoding=\"async\" class=\"size-full wp-image-42396 alignnone\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_ignoreip.jpg\" alt=\"\" width=\"647\" height=\"90\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_ignoreip.jpg 647w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_ignoreip-300x42.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_ignoreip-150x21.jpg 150w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><\/p>\n<p>Let&#8217;s keep the editor open and continue to the next step.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ban-Time-Set-Up\"><\/span>Ban Time Set-Up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The ban time is when an IP is banned after a specific number of failed authentication attempts. By default, the value is 10 minutes with 10 minutes finder on five retries. It means that Fail2ban jail with active filtering will ban the attacker&#8217;s IP address for 10 minutes after it has retried the same attack in 10 minutes (find time) x 5 times (retries).<\/p>\n<p>It is advised to set different ban times as some banning should automatically be longer than others, including retries that should be less or more. This is a personal preference, but setting the time long enough to disrupt malicious user activities is preferred. If you want to ban the attacking IP address permanently, you can set the bantime value to -1.<\/p>\n<p>In this tutorial, we are going to adjust the bantime to 60 minutes.<\/p>\n<pre>bantime = 60m<\/pre>\n<p><img decoding=\"async\" class=\"size-full wp-image-42397 alignnone\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_bantime.jpg\" alt=\"\" width=\"658\" height=\"163\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_bantime.jpg 658w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_bantime-300x74.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_bantime-150x37.jpg 150w\" sizes=\"(max-width: 658px) 100vw, 658px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Email-Notifications\"><\/span>Email Notifications<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you want to receive an email every time fail2ban bans an IP address in jail, you can set an e-mail address in the jail. Still in \/etc\/fail2ban\/jail.local, we need to modify these values. Make sure to set the <em>destemail<\/em> to your own actual email address.<\/p>\n<pre>destemail = you@yourdomain.com\r\nsender = fail2ban@host.yourserver.com<\/pre>\n<p>If you want to receive a notification email when an IP address is blocked due to failed SSH login attempt, you can put this line under [sshd] jail.<\/p>\n<pre>action = %(action_mwl)s<\/pre>\n<p>The &#8220;mwl&#8221; after the &#8220;action_&#8221; tells fail2ban to send you emails along with the logs too. If you do not want to receive the log, simply use &#8220;mw&#8221;.<\/p>\n<p>Also, make sure to enable your &#8216;sshd&#8217; jail. It should look like this.<\/p>\n<pre>[sshd]\r\n\r\n# To use more aggressive sshd modes set filter parameter \"mode\" in jail.local:\r\n# normal (default), ddos, extra or aggressive (combines all).\r\n# See \"tests\/files\/logs\/sshd\" or \"filter.d\/sshd.conf\" for usage example and details.\r\n#mode = normal\r\nport = ssh\r\nlogpath = %(sshd_log)s\r\nbackend = %(sshd_backend)s\r\n<strong>enabled = true<\/strong>\r\naction = %(action_mwl)s<\/pre>\n<p><img decoding=\"async\" class=\" wp-image-42398 alignnone\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_sshd_jail.jpg\" alt=\"\" width=\"697\" height=\"205\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_sshd_jail.jpg 697w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_sshd_jail-300x88.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_sshd_jail-150x44.jpg 150w\" sizes=\"(max-width: 697px) 100vw, 697px\" \/><\/p>\n<p>Save the changes, exit from the nano editor then restart fail2ban to load the new configuration.<\/p>\n<pre>$ sudo systemctl restart fail2ban<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Fail2ban-Jails\"><\/span>Fail2ban Jails<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In fail2ban, a jail is a combination of a filter and one or several actions. A filter could define a regular expression that matches a pattern corresponding to a failed login attempt or other suspicious activities. An action could be the command that is executed when the defined filter catches an abusive IP address. By default, there are some jails we can use, the jails with filters and actions created by the community covering many popular server applications. In this step, we will configure the default fail2ban package jails.<\/p>\n<p>Fail2ban disables the jails by default.<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-42400 alignnone\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_jails.jpg\" alt=\"\" width=\"850\" height=\"748\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_jails.jpg 850w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_jails-300x264.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_jails-150x132.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/06\/fail2ban_jails-768x676.jpg 768w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p>To enable a jail, make sure to add &#8216;<strong>enabled = true<\/strong>&#8216; under the relevant jail name.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"BanUnban-an-IP\"><\/span>Ban\/Unban an IP<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Now that fail2ban is running with some jails enabled, you need to know some basic operating commands to ban\/unban an IP address. We can use the fail2ban-client command to perform the action.<\/p>\n<p>To ban an IP address, put it in sshd jail, and run this command.<\/p>\n<pre>$ sudo fail2ban-client set sshd banip [IP_ADDRESS]<\/pre>\n<p>Sometimes you may find that fail2ban accidentally blocked an IP address, and you want to unban it. You can run these commands below to locate the jail name that banned the IP address.<\/p>\n<pre>$ sudo fail2ban-client status | grep \"Jail list\" | sed -E 's\/^[^:]+:[ \\t]+\/\/' | sed 's\/,\/\/g'<\/pre>\n<p>After getting the jail name, you can run this command to unban it finally. Do not forget to replace [IP_ADDRESS] with the actual IP address.<\/p>\n<pre>$ sudo fail2ban-client set sshd unbanip [IP_ADDRESS]<\/pre>\n<p>That\u2019s it. You have successfully installed and configured Fail2ban on Ubuntu 22.04 VPS.<\/p>\n<p>Of course, you don\u2019t have to install Fail2ban on Ubuntu 22.04 if you have a Managed Ubuntu Server with us. You can simply ask the <a href=\"https:\/\/www.rosehosting.com\/\">RoseHosting<\/a> support team to install Fail2ban on Ubuntu 22.04 for you. They are available 24\/7 and will be able to help you with the installation.<\/p>\n<p>PS. If you enjoyed reading this blog post on installing Fail2ban on Ubuntu 22.04, feel free to share it on social networks or simply leave a comment in the comments section. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fail2ban is an intrusion prevention tool that protects computers from brute force and other attacks by closely monitoring the log &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Install Fail2ban on Ubuntu 22.04\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#more-42394\" aria-label=\"Read more about How to Install Fail2ban on Ubuntu 22.04\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":42748,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1236,1703,13,1698],"tags":[280,59],"class_list":["post-42394","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","category-security","category-tutorials","category-ubuntu","tag-fail2ban","tag-ubuntu","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Install Fail2ban on Ubuntu 22.04 | RoseHosting<\/title>\n<meta name=\"description\" content=\"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install Fail2ban on Ubuntu 22.04\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-29T17:30:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-05T11:21:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"742\" \/>\n\t<meta property=\"og:image:height\" content=\"372\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Install Fail2ban on Ubuntu 22.04\" \/>\n<meta name=\"twitter:description\" content=\"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"How to Install Fail2ban on Ubuntu 22.04\",\"datePublished\":\"2022-08-29T17:30:03+00:00\",\"dateModified\":\"2022-12-05T11:21:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/\"},\"wordCount\":1042,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/how-to-install-fail2ban-on-ubuntu-22.04.webp\",\"keywords\":[\"fail2ban\",\"ubuntu\"],\"articleSection\":[\"Guides\",\"Security\",\"Tutorials\",\"Ubuntu\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/\",\"name\":\"How to Install Fail2ban on Ubuntu 22.04 | RoseHosting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/how-to-install-fail2ban-on-ubuntu-22.04.webp\",\"datePublished\":\"2022-08-29T17:30:03+00:00\",\"dateModified\":\"2022-12-05T11:21:15+00:00\",\"description\":\"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/how-to-install-fail2ban-on-ubuntu-22.04.webp\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/how-to-install-fail2ban-on-ubuntu-22.04.webp\",\"width\":742,\"height\":372,\"caption\":\"how to install fail2ban on ubuntu 22.04\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-fail2ban-on-ubuntu-22-04\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install Fail2ban on Ubuntu 22.04\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Install Fail2ban on Ubuntu 22.04 | RoseHosting","description":"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/","og_locale":"en_US","og_type":"article","og_title":"How to Install Fail2ban on Ubuntu 22.04","og_description":"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!","og_url":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2022-08-29T17:30:03+00:00","article_modified_time":"2022-12-05T11:21:15+00:00","og_image":[{"width":742,"height":372,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp","type":"image\/webp"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_title":"How to Install Fail2ban on Ubuntu 22.04","twitter_description":"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"How to Install Fail2ban on Ubuntu 22.04","datePublished":"2022-08-29T17:30:03+00:00","dateModified":"2022-12-05T11:21:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/"},"wordCount":1042,"commentCount":0,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp","keywords":["fail2ban","ubuntu"],"articleSection":["Guides","Security","Tutorials","Ubuntu"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/","url":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/","name":"How to Install Fail2ban on Ubuntu 22.04 | RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp","datePublished":"2022-08-29T17:30:03+00:00","dateModified":"2022-12-05T11:21:15+00:00","description":"In this tutorial, we will show you how to install and configure Fail2ban on Ubuntu 22.04. Read on to find out more!","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/07\/how-to-install-fail2ban-on-ubuntu-22.04.webp","width":742,"height":372,"caption":"how to install fail2ban on ubuntu 22.04"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-fail2ban-on-ubuntu-22-04\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Install Fail2ban on Ubuntu 22.04"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/42394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=42394"}],"version-history":[{"count":10,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/42394\/revisions"}],"predecessor-version":[{"id":43695,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/42394\/revisions\/43695"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/42748"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=42394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=42394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=42394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}