Restore original fail2ban configuration on CentOS 7












1















I installed fail2ban from EPEL using yum install, and then proceeded to screw up the configuration after forgetting to back up /etc/fail2ban.



Now I want the original configuration back.



First I tried yum reinstall fail2ban, but that was silly because yum install doesn't overwrite existing configuration files. Then I mved /etc/fail2ban somewhere else and tried yum reinstall fail2ban again, which according to some old blog post would give me the original configuration back. No such luck. I tried uninstalling with rpm -e and reinstalling. No such luck. I got frustrated and rm -rfed my /etc/fail2ban.backup directory, thinking maybe there was some kind of weird system discovery going on. Still nothing after reinstalling.



Finally I downloaded and unpacked the RPM source and rsynced the config directory to /etc/fail2ban, which got me most of the way there. But there are still a few differences in how the log files are set up and in how it integrates with systemd. Instead of Frankensteining something together, I really just want the original configuration back.



Is there a way to force a fresh install of an RPM package, including config and log files, either with YUM or some other tool? I'm using the standard Linode CentOS 7 image, if that matters at all.










share|improve this question



























    1















    I installed fail2ban from EPEL using yum install, and then proceeded to screw up the configuration after forgetting to back up /etc/fail2ban.



    Now I want the original configuration back.



    First I tried yum reinstall fail2ban, but that was silly because yum install doesn't overwrite existing configuration files. Then I mved /etc/fail2ban somewhere else and tried yum reinstall fail2ban again, which according to some old blog post would give me the original configuration back. No such luck. I tried uninstalling with rpm -e and reinstalling. No such luck. I got frustrated and rm -rfed my /etc/fail2ban.backup directory, thinking maybe there was some kind of weird system discovery going on. Still nothing after reinstalling.



    Finally I downloaded and unpacked the RPM source and rsynced the config directory to /etc/fail2ban, which got me most of the way there. But there are still a few differences in how the log files are set up and in how it integrates with systemd. Instead of Frankensteining something together, I really just want the original configuration back.



    Is there a way to force a fresh install of an RPM package, including config and log files, either with YUM or some other tool? I'm using the standard Linode CentOS 7 image, if that matters at all.










    share|improve this question

























      1












      1








      1








      I installed fail2ban from EPEL using yum install, and then proceeded to screw up the configuration after forgetting to back up /etc/fail2ban.



      Now I want the original configuration back.



      First I tried yum reinstall fail2ban, but that was silly because yum install doesn't overwrite existing configuration files. Then I mved /etc/fail2ban somewhere else and tried yum reinstall fail2ban again, which according to some old blog post would give me the original configuration back. No such luck. I tried uninstalling with rpm -e and reinstalling. No such luck. I got frustrated and rm -rfed my /etc/fail2ban.backup directory, thinking maybe there was some kind of weird system discovery going on. Still nothing after reinstalling.



      Finally I downloaded and unpacked the RPM source and rsynced the config directory to /etc/fail2ban, which got me most of the way there. But there are still a few differences in how the log files are set up and in how it integrates with systemd. Instead of Frankensteining something together, I really just want the original configuration back.



      Is there a way to force a fresh install of an RPM package, including config and log files, either with YUM or some other tool? I'm using the standard Linode CentOS 7 image, if that matters at all.










      share|improve this question














      I installed fail2ban from EPEL using yum install, and then proceeded to screw up the configuration after forgetting to back up /etc/fail2ban.



      Now I want the original configuration back.



      First I tried yum reinstall fail2ban, but that was silly because yum install doesn't overwrite existing configuration files. Then I mved /etc/fail2ban somewhere else and tried yum reinstall fail2ban again, which according to some old blog post would give me the original configuration back. No such luck. I tried uninstalling with rpm -e and reinstalling. No such luck. I got frustrated and rm -rfed my /etc/fail2ban.backup directory, thinking maybe there was some kind of weird system discovery going on. Still nothing after reinstalling.



      Finally I downloaded and unpacked the RPM source and rsynced the config directory to /etc/fail2ban, which got me most of the way there. But there are still a few differences in how the log files are set up and in how it integrates with systemd. Instead of Frankensteining something together, I really just want the original configuration back.



      Is there a way to force a fresh install of an RPM package, including config and log files, either with YUM or some other tool? I'm using the standard Linode CentOS 7 image, if that matters at all.







      centos yum configuration rpm fail2ban






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 4 '17 at 23:16









      shadowtalkershadowtalker

      458517




      458517






















          3 Answers
          3






          active

          oldest

          votes


















          1














          I think yum is too conservative to do what you want. For best results, you should also be prepared to use some rpm commands.



          this will scrub all of the files rpm (ergo yum) know/trust belong to the fail2ban package.



          rpm -e --justdb --nodeps fail2ban


          After that, you can remove/move your /etc files and yum will reinstall.



          All the magic yum/rpm is doing with config files is in the RPM spec file in lines with the prefix "%config(noreplace)" with the macro "%{_sysconfdir}" which means '/etc' in your case. Just get those all out of the way, and the rpm will install all of its default config files.



          %config(noreplace) %{_sysconfdir}/fail2ban
          %config(noreplace) %{_sysconfdir}/logrotate.d/fail2ban
          %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-firewalld.conf
          %config(noreplace) %{_sysconfdir}/fail2ban/action.d/hostsdeny.conf
          %config(noreplace) %{_sysconfdir}/fail2ban/action.d/complain.conf
          %config(noreplace) %{_sysconfdir}/fail2ban/action.d/mail-*.conf
          %config(noreplace) %{_sysconfdir}/fail2ban/action.d/sendmail-*.conf
          %config(noreplace) %{_sysconfdir}/fail2ban/action.d/shorewall.conf
          %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-systemd.conf


          Have a look for yourself:



          curl 'http://pkgs.fedoraproject.org/cgit/rpms/fail2ban.git/plain/fail2ban.spec?h=epel7' |
          grep '^%config(noreplace)'





          share|improve this answer
























          • This didn't work. rpm -e --justdb --nodeps fail2ban succeeded silently, rm -rf /etc/fail2ban went as expected, but then yum install fail2ban didn't replace the files I deleted. Thanks for the tip about the spec file, though.

            – shadowtalker
            Mar 5 '17 at 6:14













          • Did you get any /etc/fail2ban files when reinstalling? Did you notice that you also need to clean out /etc/logrotate.d/fail2ban? The next step is for you to download the fail2ban rpm and install it with "rpm -i -vv --allfiles --force fail2ban-0.9.6-3.el7.noarch.rpm"

            – Jeremy
            Mar 7 '17 at 14:41











          • it turns out the config files were regenerated when I installed the dependency packages. See my answer (unix.stackexchange.com/a/349231/73256). Not sure what exactly happened but I'm happy it's fixed.

            – shadowtalker
            Mar 7 '17 at 15:29





















          1














          On my system, fail2ban is actually spread across several packages:




          • fail2ban

          • fail2ban-firewalld

          • fail2ban-systemd

          • fail2ban-sendmail

          • fail2ban-server

          • systemd-python


          Evidently, the configuration files don't get generated unless some or all of the above are installed. yum autoremove got rid of them, and then yum install fail2ban restored the original config files.






          share|improve this answer































            1














            I needed to do this steps to solve the same problem:



            sudo yum autoremove fail2ban -y
            sudo yum autoremove fail2ban-server -y
            sudo yum install fail2ban -y





            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "106"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f349198%2frestore-original-fail2ban-configuration-on-centos-7%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              I think yum is too conservative to do what you want. For best results, you should also be prepared to use some rpm commands.



              this will scrub all of the files rpm (ergo yum) know/trust belong to the fail2ban package.



              rpm -e --justdb --nodeps fail2ban


              After that, you can remove/move your /etc files and yum will reinstall.



              All the magic yum/rpm is doing with config files is in the RPM spec file in lines with the prefix "%config(noreplace)" with the macro "%{_sysconfdir}" which means '/etc' in your case. Just get those all out of the way, and the rpm will install all of its default config files.



              %config(noreplace) %{_sysconfdir}/fail2ban
              %config(noreplace) %{_sysconfdir}/logrotate.d/fail2ban
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-firewalld.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/hostsdeny.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/complain.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/mail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/sendmail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/shorewall.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-systemd.conf


              Have a look for yourself:



              curl 'http://pkgs.fedoraproject.org/cgit/rpms/fail2ban.git/plain/fail2ban.spec?h=epel7' |
              grep '^%config(noreplace)'





              share|improve this answer
























              • This didn't work. rpm -e --justdb --nodeps fail2ban succeeded silently, rm -rf /etc/fail2ban went as expected, but then yum install fail2ban didn't replace the files I deleted. Thanks for the tip about the spec file, though.

                – shadowtalker
                Mar 5 '17 at 6:14













              • Did you get any /etc/fail2ban files when reinstalling? Did you notice that you also need to clean out /etc/logrotate.d/fail2ban? The next step is for you to download the fail2ban rpm and install it with "rpm -i -vv --allfiles --force fail2ban-0.9.6-3.el7.noarch.rpm"

                – Jeremy
                Mar 7 '17 at 14:41











              • it turns out the config files were regenerated when I installed the dependency packages. See my answer (unix.stackexchange.com/a/349231/73256). Not sure what exactly happened but I'm happy it's fixed.

                – shadowtalker
                Mar 7 '17 at 15:29


















              1














              I think yum is too conservative to do what you want. For best results, you should also be prepared to use some rpm commands.



              this will scrub all of the files rpm (ergo yum) know/trust belong to the fail2ban package.



              rpm -e --justdb --nodeps fail2ban


              After that, you can remove/move your /etc files and yum will reinstall.



              All the magic yum/rpm is doing with config files is in the RPM spec file in lines with the prefix "%config(noreplace)" with the macro "%{_sysconfdir}" which means '/etc' in your case. Just get those all out of the way, and the rpm will install all of its default config files.



              %config(noreplace) %{_sysconfdir}/fail2ban
              %config(noreplace) %{_sysconfdir}/logrotate.d/fail2ban
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-firewalld.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/hostsdeny.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/complain.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/mail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/sendmail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/shorewall.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-systemd.conf


              Have a look for yourself:



              curl 'http://pkgs.fedoraproject.org/cgit/rpms/fail2ban.git/plain/fail2ban.spec?h=epel7' |
              grep '^%config(noreplace)'





              share|improve this answer
























              • This didn't work. rpm -e --justdb --nodeps fail2ban succeeded silently, rm -rf /etc/fail2ban went as expected, but then yum install fail2ban didn't replace the files I deleted. Thanks for the tip about the spec file, though.

                – shadowtalker
                Mar 5 '17 at 6:14













              • Did you get any /etc/fail2ban files when reinstalling? Did you notice that you also need to clean out /etc/logrotate.d/fail2ban? The next step is for you to download the fail2ban rpm and install it with "rpm -i -vv --allfiles --force fail2ban-0.9.6-3.el7.noarch.rpm"

                – Jeremy
                Mar 7 '17 at 14:41











              • it turns out the config files were regenerated when I installed the dependency packages. See my answer (unix.stackexchange.com/a/349231/73256). Not sure what exactly happened but I'm happy it's fixed.

                – shadowtalker
                Mar 7 '17 at 15:29
















              1












              1








              1







              I think yum is too conservative to do what you want. For best results, you should also be prepared to use some rpm commands.



              this will scrub all of the files rpm (ergo yum) know/trust belong to the fail2ban package.



              rpm -e --justdb --nodeps fail2ban


              After that, you can remove/move your /etc files and yum will reinstall.



              All the magic yum/rpm is doing with config files is in the RPM spec file in lines with the prefix "%config(noreplace)" with the macro "%{_sysconfdir}" which means '/etc' in your case. Just get those all out of the way, and the rpm will install all of its default config files.



              %config(noreplace) %{_sysconfdir}/fail2ban
              %config(noreplace) %{_sysconfdir}/logrotate.d/fail2ban
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-firewalld.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/hostsdeny.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/complain.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/mail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/sendmail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/shorewall.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-systemd.conf


              Have a look for yourself:



              curl 'http://pkgs.fedoraproject.org/cgit/rpms/fail2ban.git/plain/fail2ban.spec?h=epel7' |
              grep '^%config(noreplace)'





              share|improve this answer













              I think yum is too conservative to do what you want. For best results, you should also be prepared to use some rpm commands.



              this will scrub all of the files rpm (ergo yum) know/trust belong to the fail2ban package.



              rpm -e --justdb --nodeps fail2ban


              After that, you can remove/move your /etc files and yum will reinstall.



              All the magic yum/rpm is doing with config files is in the RPM spec file in lines with the prefix "%config(noreplace)" with the macro "%{_sysconfdir}" which means '/etc' in your case. Just get those all out of the way, and the rpm will install all of its default config files.



              %config(noreplace) %{_sysconfdir}/fail2ban
              %config(noreplace) %{_sysconfdir}/logrotate.d/fail2ban
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-firewalld.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/hostsdeny.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/complain.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/mail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/sendmail-*.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/action.d/shorewall.conf
              %config(noreplace) %{_sysconfdir}/fail2ban/jail.d/00-systemd.conf


              Have a look for yourself:



              curl 'http://pkgs.fedoraproject.org/cgit/rpms/fail2ban.git/plain/fail2ban.spec?h=epel7' |
              grep '^%config(noreplace)'






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 5 '17 at 0:01









              JeremyJeremy

              7614




              7614













              • This didn't work. rpm -e --justdb --nodeps fail2ban succeeded silently, rm -rf /etc/fail2ban went as expected, but then yum install fail2ban didn't replace the files I deleted. Thanks for the tip about the spec file, though.

                – shadowtalker
                Mar 5 '17 at 6:14













              • Did you get any /etc/fail2ban files when reinstalling? Did you notice that you also need to clean out /etc/logrotate.d/fail2ban? The next step is for you to download the fail2ban rpm and install it with "rpm -i -vv --allfiles --force fail2ban-0.9.6-3.el7.noarch.rpm"

                – Jeremy
                Mar 7 '17 at 14:41











              • it turns out the config files were regenerated when I installed the dependency packages. See my answer (unix.stackexchange.com/a/349231/73256). Not sure what exactly happened but I'm happy it's fixed.

                – shadowtalker
                Mar 7 '17 at 15:29





















              • This didn't work. rpm -e --justdb --nodeps fail2ban succeeded silently, rm -rf /etc/fail2ban went as expected, but then yum install fail2ban didn't replace the files I deleted. Thanks for the tip about the spec file, though.

                – shadowtalker
                Mar 5 '17 at 6:14













              • Did you get any /etc/fail2ban files when reinstalling? Did you notice that you also need to clean out /etc/logrotate.d/fail2ban? The next step is for you to download the fail2ban rpm and install it with "rpm -i -vv --allfiles --force fail2ban-0.9.6-3.el7.noarch.rpm"

                – Jeremy
                Mar 7 '17 at 14:41











              • it turns out the config files were regenerated when I installed the dependency packages. See my answer (unix.stackexchange.com/a/349231/73256). Not sure what exactly happened but I'm happy it's fixed.

                – shadowtalker
                Mar 7 '17 at 15:29



















              This didn't work. rpm -e --justdb --nodeps fail2ban succeeded silently, rm -rf /etc/fail2ban went as expected, but then yum install fail2ban didn't replace the files I deleted. Thanks for the tip about the spec file, though.

              – shadowtalker
              Mar 5 '17 at 6:14







              This didn't work. rpm -e --justdb --nodeps fail2ban succeeded silently, rm -rf /etc/fail2ban went as expected, but then yum install fail2ban didn't replace the files I deleted. Thanks for the tip about the spec file, though.

              – shadowtalker
              Mar 5 '17 at 6:14















              Did you get any /etc/fail2ban files when reinstalling? Did you notice that you also need to clean out /etc/logrotate.d/fail2ban? The next step is for you to download the fail2ban rpm and install it with "rpm -i -vv --allfiles --force fail2ban-0.9.6-3.el7.noarch.rpm"

              – Jeremy
              Mar 7 '17 at 14:41





              Did you get any /etc/fail2ban files when reinstalling? Did you notice that you also need to clean out /etc/logrotate.d/fail2ban? The next step is for you to download the fail2ban rpm and install it with "rpm -i -vv --allfiles --force fail2ban-0.9.6-3.el7.noarch.rpm"

              – Jeremy
              Mar 7 '17 at 14:41













              it turns out the config files were regenerated when I installed the dependency packages. See my answer (unix.stackexchange.com/a/349231/73256). Not sure what exactly happened but I'm happy it's fixed.

              – shadowtalker
              Mar 7 '17 at 15:29







              it turns out the config files were regenerated when I installed the dependency packages. See my answer (unix.stackexchange.com/a/349231/73256). Not sure what exactly happened but I'm happy it's fixed.

              – shadowtalker
              Mar 7 '17 at 15:29















              1














              On my system, fail2ban is actually spread across several packages:




              • fail2ban

              • fail2ban-firewalld

              • fail2ban-systemd

              • fail2ban-sendmail

              • fail2ban-server

              • systemd-python


              Evidently, the configuration files don't get generated unless some or all of the above are installed. yum autoremove got rid of them, and then yum install fail2ban restored the original config files.






              share|improve this answer




























                1














                On my system, fail2ban is actually spread across several packages:




                • fail2ban

                • fail2ban-firewalld

                • fail2ban-systemd

                • fail2ban-sendmail

                • fail2ban-server

                • systemd-python


                Evidently, the configuration files don't get generated unless some or all of the above are installed. yum autoremove got rid of them, and then yum install fail2ban restored the original config files.






                share|improve this answer


























                  1












                  1








                  1







                  On my system, fail2ban is actually spread across several packages:




                  • fail2ban

                  • fail2ban-firewalld

                  • fail2ban-systemd

                  • fail2ban-sendmail

                  • fail2ban-server

                  • systemd-python


                  Evidently, the configuration files don't get generated unless some or all of the above are installed. yum autoremove got rid of them, and then yum install fail2ban restored the original config files.






                  share|improve this answer













                  On my system, fail2ban is actually spread across several packages:




                  • fail2ban

                  • fail2ban-firewalld

                  • fail2ban-systemd

                  • fail2ban-sendmail

                  • fail2ban-server

                  • systemd-python


                  Evidently, the configuration files don't get generated unless some or all of the above are installed. yum autoremove got rid of them, and then yum install fail2ban restored the original config files.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 5 '17 at 6:21









                  shadowtalkershadowtalker

                  458517




                  458517























                      1














                      I needed to do this steps to solve the same problem:



                      sudo yum autoremove fail2ban -y
                      sudo yum autoremove fail2ban-server -y
                      sudo yum install fail2ban -y





                      share|improve this answer




























                        1














                        I needed to do this steps to solve the same problem:



                        sudo yum autoremove fail2ban -y
                        sudo yum autoremove fail2ban-server -y
                        sudo yum install fail2ban -y





                        share|improve this answer


























                          1












                          1








                          1







                          I needed to do this steps to solve the same problem:



                          sudo yum autoremove fail2ban -y
                          sudo yum autoremove fail2ban-server -y
                          sudo yum install fail2ban -y





                          share|improve this answer













                          I needed to do this steps to solve the same problem:



                          sudo yum autoremove fail2ban -y
                          sudo yum autoremove fail2ban-server -y
                          sudo yum install fail2ban -y






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 7 at 16:03









                          SarogahtypSarogahtyp

                          111




                          111






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f349198%2frestore-original-fail2ban-configuration-on-centos-7%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How to make a Squid Proxy server?

                              Is this a new Fibonacci Identity?

                              19世紀