How to generate linux server certificates

  1. Generate a Private Key
openssl genrsa -des3 -out server.key 1024
  1. Generate a CSR (Certificate Signing Request)
openssl req -new -key server.key -out server.csr
  1. Remove Passphrase from Key
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
  1. Generating a Self-Signed Certificate
openssl x509 -req -days 1365 -in server.csr -signkey server.key -out server.crt
  1. Installing the Private Key and Certificate
cp server.crt /etc/pki/tls/certs/ssl.crt
cp server.key /etc/pki/tls/private/ssl.key

 

Fail2ban Status commands

fail2ban-client status postfix

Show status of all fail2ban jails at once
create the file fail2ban-allstatus.sh
#!/bin/bash
JAILS=`fail2ban-client status | grep Jail list | sed -E s/^[^:]+:[ \t]+// | sed s/,//g`
for JAIL in $JAILS
do
fail2ban-client status $JAIL
done

or with a command

fail2ban-client status|awk -F: ‘/Jail list:/ { split($2,jail,”,”) ; for (i in jail) { gsub(/[\t ]/,””,jail[i]); system(“fail2ban-client status “jail[i]); }; }’

grep -srni “journalmatch” /etc/fail2ban/filter.d/

 

Yum warning

After a yum update I receive this worning :

warning: /etc/fail2ban/jail.conf created as /etc/fail2ban/jail.conf.rpmnew

Those warnings are expected if you have made changes to your configuration files. yum is kind enough to not overwrite your existing modified configuration, but instead writes the new default configuration file to a .rpmnew file, which you can then review and perhaps incorporate the new defaults etc to your own configuration. This is OK. The kernel module warnings are also of no concern.

 

How to Use Virtual Environments

Useful command for python system environment or custom environment.
When any environment is not activated you are using the system environment.
pip list
pip3 list
create new environment :
python3 -m venv env_name
create a directory env_name
activate the env_name :
source env_name/bin/activate
show which python :
which python
deactivate environment :
deactivate
create an environment with the same packages of the system environment :
python3 -m venv env_name –system-site-packages
how to show the only packages installed in the env_name environment
pip list –local

ES:

python3.6 -m venv pgAdminEnv

source pgAdminEnv/bin/activate

Yum clean package and fix duplicate packages

From time to time, the yum package manager may encounter issues with duplicate packages that are erroneously installed on a system. This manifests in a yum update going awry, telling us something along the lines of this:

You may at times install all other packages via yum update –skip-broken, but it will still leave some trouble on the system. Best to take care of it.

Here’s how I’ve managed to do it on many occasions:

Installing yum-utils

The utility that will help us fix these issues is called package-cleanup, and it’s part of the yum-utils package. Let’s install that first before we continue:

Next, let’s see what’s wrong with our system. package-cleanup –dupes will show us duplicate packages on the system:

The list could go on. Here we see that several packages are seemingly installed more than once. The –cleandupes parameter will take care of this, erasing such superfluous packages:

The process will look very similar to a yum update, with yum verifying and erasing the duplicates. It doesn’t hurt to make a note of the erased packages and check if the latest version is still installed. Should this not be the case, you can bring those packages back with “yum reinstall packagename”.

Finishing Up

At this point, let’s try to update the system again with a standard yum update command. This should take care of any missing dependencies that may have been removed in the previous process, and of course it’ll update the rest of your system too, hopefully taking care of the initial problem.

Finally, to see if there’s any remaining trouble with the yum database, we can issue the following and are – hopefully – greeted with the same message: