Ahmad Mahfouz

Random notes

Category: Linux

SSH Tunnelling

the most famous method is using D parameter in ssh connection to bind a port local in your machine and this port tunnel back to our remote box to send our traffic to this server example

then you can configure your application and browser to use your local IP 127.0.0.1 with the port 1337

Secure/Lock accounts with PAM tally2

pam_tally2 is a PAM module to allow interaction in users interfaces on numbers of failed login attempt it can reset count on success, can deny access if too many attempts fail. this module is unique because it  not just reflect remote connection but also reflect the ttys and any system login method as it uses PAM example

password policy with pam_cracklib

cracklib pam module is a method to check the password against dictionary list and gives you availability to check the strength of the password and set rules to identify the poor passwords   here is the most important parameters for this module  minlen minimal password length dcredit maximum number of digits ucredit maximum uppercase letters

Pluggable Authentication Modules

Linux comes with Pam Modules to help you to interact with the running services in hardening way and custom the security of the service as you need. PAM is extra Rules to Control user interfaces ( Auth, Account, Session)  layers for the applications the applications/services should be compiled with libpam.so here is an example for

users in shadow file explanation

this article explain the /etc/shadow this file content the users information example of the user data

username -> n1x password -> $6$UoDmVdoW$tYQQm5uHgOpeEKPygIaQ1GM/0IBbdYVrLHu8ZYF5pT17D3VM.FFKa2wS8J6gqbGKC2IpgImXy7SYVJK9r/fdw. last date password update since 1970-1-1 -> 16631 you can calculate it simply in python

minmum password age -> 7 maximum password age -> 15 warning days -> 2 inactive days

AIDE : Intrusion Detection Environment

this article about Intrusion Detection for file system changes like modification changing owner extra, for critical files or directories in our environment we using a software called AIDE Advanced Intrusion Detections Environment this software base on a library called mhash this lib used to calculate file hashes and AIDE save the file info inside DB

umask permissions explanation

what is umask? umask is the default permissions for writing a file in the system where the settings for umask? 1 – /etc/profile 2 – /etc/bashrc

Persistent mount for luks with unlock Key

creating a encrypted disk with luks our  Little problem here to mount a encrypted disk  automatically on boot so no need to enter the pass for mounting but this risky if the machine theft happen because we will use a key inside the system and it will be leaked if our machine stolen so lets

Linux Disk Encryption with LUKS

today we going to make an encrypted disk partition list prepare our partition I have a new disk in  /dev/sdb I will create a partition 100 on it with fdisk

RPM integrity and scripts

Yum repository comes with gpg  and md5 support to verify the validity of the package You can list installed gpg keys in your system via

It will show the unique id for the installed keys in your  system gpg-pubkey-e8562897-459f07a4 gpg-pubkey-217521f6-45e8a532 To list all information related to a key rpm -qi pgp-key-unique-id

  It