How to tell to fail2ban what init system are you running

I owed myself a fail2ban installation on the Raspberry Pi. A simple view of this log tell you many things:

Jun 17 07:54:15 raspberrypi systemd[1]: Starting Fail2Ban Service...
Jun 17 07:54:28 raspberrypi fail2ban-client[11687]: ERROR No file(s) found for glob /var/log/proftpd/proftpd.log
Jun 17 07:54:28 raspberrypi fail2ban-client[11687]: ERROR Failed during configuration: Have not found any log file for proftpd jail
Jun 17 07:54:29 raspberrypi systemd[1]: fail2ban.service: Control process exited, code=exited status=255
Jun 17 07:54:29 raspberrypi systemd[1]: Failed to start Fail2Ban Service.
Jun 17 07:54:29 raspberrypi systemd[1]: fail2ban.service: Unit entered failed state.
Jun 17 07:54:29 raspberrypi systemd[1]: fail2ban.service: Failed with result 'exit-code'.
Jun 17 07:54:29 raspberrypi systemd[1]: fail2ban.service: Service hold-off time over, scheduling restart.
Jun 17 07:54:29 raspberrypi systemd[1]: Stopped Fail2Ban Service.
Jun 17 07:54:29 raspberrypi systemd[1]: Starting Fail2Ban Service...

You may notice I’ve tried to start up Fail2ban unsuccesfully. So let’s debug…
It appears an error that informs there’s no proftd.log. The second line points to the same log file, but related with fail2ban configuration (jail, here means fail2ban configuration).

After digging a lit bit I’ve found that fail2ban sets as auto its configuration and try to guess if your system is managed by systemd, traditional systemV init scripts or whatever. I edit the /etc/fail2ban/jail.conf, I set backend = systemd and fail2ban starts up succesfully.

How do you indetify an USB and get it mounted in your Linux?

I’m using a RaspberryPi to enforce myself to keep learning.

I’ve added an old 8Gb USB stick to the RaspberryPi. The Raspberry runs a very minimal Raspbian Strech Lite without assistants, or graphical interface, not even with the automunt command.

So, how do you identify the USB stick plugged and get it mounted or your Linux?

  1. Plug your USB stick to your RaspberryPi
  2. Run the command blkid as root.
    As an example I type:

    sudo blkid

    … and I get:

    /dev/mmcblk0p1: LABEL="boot" UUID="CDD4-B453" TYPE="vfat" PARTUUID="b1b51741-01"
    /dev/mmcblk0p2: LABEL="rootfs" UUID="72bfc10d-73ec-4d9e-a54a-1cc507ee7ed2" TYPE="ext4" PARTUUID="b1b51741-02"
    /dev/sda: LABEL="USB8GB" UUID="B21F-17E5" TYPE="vfat"
    /dev/mmcblk0: PTUUID="b1b51741" PTTYPE="dos"

    This line identify what device is used by the USB stick just plugged /dev/sda: LABEL="USB8GB" UUID="B21F-17E5" TYPE="vfat"

  3. Now we can mount normally the device by typing:

    sudo mount -t vfat /dev/sda /mnt/

What is the motivation of this post? I’ve to managed myself in order to get mounted the USB stick since the command lsusb gave me a lot of info but no so usefull, or simple, to get it mounted.

How to modify every day login in Linux

Every time you log into a *NIX machine you are wellcomed by a text banner that varies from one *NIX to other, even among Linux distributions.

If you want to customized this message it’s fairly easy, you only have to edit (as a root) the file /etc/motd and the next login will show your new message of the day.

My two cents to a so simple task is enrich your file writting inside some ASCII art. For instance, you may use figlet to writte inside the /etc/motd file your hostname. In short:

  1. Be sure you have figlet installed in your system or install: in Fedora; type yum list figlet or (lazy way) yum list figl* and figlet may appears in one of both list, installed or available package.
  2. Add different messages to each login with fortunes. First, be sure you have fortunes installed in your Fedora and then, edit your .profile and add an invocation to the fortunes program.
    For instance, I add this:
    echo -n "### Fortune for "
    echo -n `date +%d\-\%m\-\%Y`
    echo " ###"

    I get this:
    ### Fortune for 22-04-2018 ###
    Computers are useless. They can only give you answers.
    -- Pablo Picasso

    BTW, I recommend to writte the full path to the fortune’s binary ’cause it’s installed out of the usual $PATH.

If you research a few over thhe Internet you may find differente fortunes collections, such The Simpsons, or my favorites inspired by BOFH.

How to ask for root password when using sudo

A minimal improvement to your security is asking for a password when you allow normal users to execute privileges command via sudo. Usually, they just type their own password and that allows they to gaing privileged status to execute what you have set in sudo files.

You should consider change this behaviour and ask for root password. Why? it’s too easy IMHO to execute a root command because the user (or impostor) only needs to know one single password and not your root password but someone elses one.

Instead of that setting I prefer to change sudo files to this in the /etc/sudoers:

Defaults rootpw

Before do that, be sure your root password is setted and accomplish a minimul security recommendations. It will not apply in current shells, but the new ones.