Skip to content

Instantly share code, notes, and snippets.

@parrazam
parrazam / ssh_alert_script_pam.sh
Last active May 31, 2023 15:35
SSH session alert script
#!/bin/bash
# This script should be allocated in /etc/pam.scripts/ssh_alert.sh
# Then, in /etc/pam.d/sshd add this line:
# # SSH Alert script
# session required pam_exec.so /etc/pam.scripts/ssh_alert.sh
echo $PAM_TYPE
@parrazam
parrazam / publishMessageToTelegramBot.sh
Created May 25, 2020 09:27
Publish message to a Telegram bot
#!/bin/bash
if [[ $# -ne 1 ]]
then
echo "\nSe requiere un mensaje para enviar. Ejemplo de uso: $0 \"Mensaje de prueba\""
exit 1
fi
source /home/$USER/.tg_keys

$argon2id$v=19$m=64,t=512,p=2$gXOmC37WMMywKRmjMGazDg$FkA/Zh5lTtovWBgbGRyFJg

@parrazam
parrazam / customactions.conf
Created June 4, 2020 15:03
Fail2Ban custom actions
[Definition]
# Option: actionstart
# Notes : command executed once at the start of Fail2Ban
# Tags :
# Values: CMD
actionstart =
# Option: actionstop
# Notes : command executed once at the end of Fail2Ban
@parrazam
parrazam / jail.local
Created June 4, 2020 15:01
Fail2Ban jail local
[sshd]
# To use more aggressive ssh modes set filter parameter "mode":
# normal (default), ddos, extra or aggressive (combines all).
# See "tests/files/logs/sshd" or "filter.d/sshd.conf" for usage example and details.
#mode = normal
port = ssh
enabled = true
filter = sshd
ignoreip = 192.168.1.0/24
@parrazam
parrazam / baja_usuarios.pl
Created May 24, 2020 17:33
Script en Perl para dar de baja un usuario
#!/usr/bin/perl
# Script que permite dar de baja un usuario.
# Author: Víctor Parra [parra@usal.es]
# AVISO: Requiere permisos de root
# Es necesario instalar el File::Path y el Linux::usermod
# ># perl -MCPAN -e 'install File::Path'
# ># perl -MCPAN -e 'install Linux::usermod'
@parrazam
parrazam / alta_usuarios.pl
Created May 24, 2020 17:31
Script en Perl para dar de alta un usuario
#!/usr/bin/perl
# Script que permite dar de alta un usuario.
# Author: Víctor Parra [parra@usal.es]
# AVISO: Requiere permisos de root
# Es necesrio instalar el File::Copy y el Linux::usermod
# ># perl -MCPAN -e 'install File::Copy::Recursive'
# ># perl -MCPAN -e 'install Linux::usermod'