Pages

Saturday, November 7, 2015

Enforce Password Complexity in Linux Server

You can use PAM to enforce password complexity in Linux Systems. For Debian / Ubuntu you can use the following file:
/etc/pam.d/common-password


First install the package.
apt-get install libpam-cracklib


Edit "/etc/pam.d/common-password" as per your requirement.

password requisite pam_cracklib.so try_first_pass retry=3 minlength=6 lcredit=1 ucredit=1 dcredit=0 ocredit=1 difok=4

** try_first_pass retry=3 [Number of times to password change retry]
** minlength = 6 [Minimum password length is 6]
** lcredit =1 [Minimum lowercase character is 1]
** ucredit = 1 [Minimum uppercase character is 1]
** dcredit = 0 [Minimum number is 0]
** ocredit = 1 [Minimum number of other character / simbols is 1]
** difok = 4 [New password must be different from previous 4 passwords]


Now modify the options as you need. You can omit options like below.
password requisite pam_cracklib.so try_first_pass retry=3 minlength=6 ucredit=1 dcredit=1 


Save the file and you are done.

Monday, September 21, 2015

htaccess apache2 authentication for specific directory

@@ Apache version 2.4 and above. @@

Create .htaccess file in /var/www/html directory and add following lines

********************************
AuthType Basic
AuthName "Password Required"
AuthUserFile /var/www/html/webmail/.htpasswd
AuthGroupFile /dev/null
Require user webmail

*******************************


Create another file for storing password and save it as blank file
vim /var/www/html/webmail/.htpasswd


Create & store password
htpasswd -m /var/www/html/webmail/.htpasswd webmail


Now enable a module with below command
a2enmod authz_groupfile

Restart apache2 service



Edit apache.conf file with below lines
AccessFileName .htaccess [remove hash (#) in front of this line]

Change below lines from
**********************************
<Directory /var/www>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

*********************************

to
*********************************
<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

*********************************


Restart apache2 service and check now. It will prompt you for username and password.

Saturday, July 4, 2015

Mikrotik Router BGP Configuration

Today we will learn how to configure BGP routing protocol to ensure auto failover of multiple links from your ISP. Let me describe the scenario first.

Platform: Mikrotik Router
Primary Link IP: 172.17.176.4/27
Secondary Link IP: 172.17.160.6/27
Usable Subnet: 172.17.161.0/30
My ASN: 65503
Remote [ISP] ASN: 203


Here is the connectivity diagram:





So, Let's start the configuration. At first we will assign the primary IP address in ether1, Secondary IP address in ether2 and my usable subnet IP address ether3 interfaces.




Primary IP address assign:



Secondary IP address assign:


My usable IP subnet:


Now we need to create filters to configure BGP. Here is how to do that.





In this case my ISP should send the default route to my router and all other routes should be discarded. Let's see how to create those filters.



A BGP attribute named "local preference" can be used to mark the primary link. Usually BGP uses the default value "local preference = 100" if we don't mention any value for this attribute.



The rule is "Higher local preference will get higher priority". So we set the value to 200 to make a link as Primary link in our configuration.






To discard all other incoming routes do the following.





Do the same thing for Secondary link as well.







We have already finished the configuration of incoming filters. Now we should mention the outgoing filters as well. My ISP should receive the given IP subnet [172.17.161.0/30] from me.

We need to create outgoing filters for Primary and Secondary links as well.










Now start with BGP. Follow the steps below to configure it.















 The final checking for our BGP configuration.







We are done.