Restore original fail2ban configuration on CentOS 7
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 mv
ed /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 -rf
ed 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 rsync
ed 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
add a comment |
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 mv
ed /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 -rf
ed 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 rsync
ed 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
add a comment |
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 mv
ed /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 -rf
ed 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 rsync
ed 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
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 mv
ed /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 -rf
ed 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 rsync
ed 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
centos yum configuration rpm fail2ban
asked Mar 4 '17 at 23:16
shadowtalkershadowtalker
458517
458517
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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)'
This didn't work.rpm -e --justdb --nodeps fail2ban
succeeded silently,rm -rf /etc/fail2ban
went as expected, but thenyum 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
add a comment |
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.
add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)'
This didn't work.rpm -e --justdb --nodeps fail2ban
succeeded silently,rm -rf /etc/fail2ban
went as expected, but thenyum 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
add a comment |
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)'
This didn't work.rpm -e --justdb --nodeps fail2ban
succeeded silently,rm -rf /etc/fail2ban
went as expected, but thenyum 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
add a comment |
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)'
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)'
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 thenyum 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
add a comment |
This didn't work.rpm -e --justdb --nodeps fail2ban
succeeded silently,rm -rf /etc/fail2ban
went as expected, but thenyum 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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 5 '17 at 6:21
shadowtalkershadowtalker
458517
458517
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Feb 7 at 16:03
SarogahtypSarogahtyp
111
111
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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