Home » 2015 » July

WordPress – password protect

Ok, in order to harden your WordPress installation, the easiest and fastest thing you can do is to add another layer of authentication to wp-admin area.
If your web server is Apache, you can use htaccess files to do this.

First, create the user and password file. Use a Htpasswd generator and make sure to put the path outside the document root of your website.

Now, you need to edit two .htaccess files.

The one in wp-admin/.htaccess (create it if it doesn’t exists) should contain these lines:

#Avoid the too many redirects error
ErrorDocument 401 "Denied"
ErrorDocument 403 "Denied"

# Allow plugin access to admin-ajax.php around password protection

Order allow,deny
Allow from all
Satisfy any

#Basic authentication
AuthType Basic
AuthName "Secure Area"
AuthUserFile "/path/to/.htpasswd"
require valid-user

And in the main .htaccess file from the document root of your website, add these lines after the WordPress rewrite rules:

#Avoid the too many redirects error
ErrorDocument 401 "Denied"
ErrorDocument 403 "Denied"

AuthType Basic
AuthName "Secure Area"
AuthUserFile "/path/to/.htpasswd"
require valid-user

I’ll update this post with the nGinx configuration, if that’s your case.


I was working on a Debian 5 (Lenny) box and needed to generate a key.
So, ok, let’s do gpg �gen-key , filled in the required info, and let’s generate that key, when, suddenly:

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 258 more bytes)

What? What entropy? Do what? Use the keyboard, disk ?
Well, apparently, there is no joke, you really need some activity going on the system in order to generate the key.

I did ls -R / and it started to generate the key.

To see the entropy of the system: cat /proc/sys/kernel/random/entropy_avail

Now I wonder, do we have entropy on Windows?

ESX � How to Power off an unresponsive VM

It happened to me the other day, the vm was stuck because another process was locked (a snapshot in my case).

I found out that the best way is this:

1. Log in to ESX console and determine the WorldID with the command:

# vm-support -x

2. Determine the master world ID with the command:

# less -S /proc/vmware/vm/****/cpu/status

or on Vsphere

less -S /proc/vmware/vm/****/names

3. Scroll to the right with the arrow keys until you see the group field. It appears similar to:


4. Run the following command to shut the virtual machine down with the group ID:

# /usr/lib/vmware/bin/vmkload_app -k 9 ****

If the preceding steps fail, perform the following steps for an ESX 4.x host:

1. List all running virtual machines to find the vmxCartelID of the affected virtual machine with the command:

# /usr/lib/vmware/bin/vmdumper -l

2. Scroll through the list until you see your virtual machine�s name. The output appears similar to:

vmid=5151 pid=-1 cfgFile=�/vmfs/volumes/4a16a48a-d807aa7e-e674-001e4ffc52e9/mdineeen_test/vm_test.vmx� uuid=�56 4d a6 db 0a e2 e5 3e-a9 2b 31 4b 69 29 15 19? displayName=�vm_test� vmxCartelID=####

3. Run the following command to shut the virtual machine down with the vmxCartelID:

# /usr/lib/vmware/bin/vmkload_app -k 9 ####

How to resize LVM (extend or reduce)

Logical Volume Manager is great, you can manage your disks and partitions in volumes. The most common task is to extend a volume or reduce one.

You can extend a volume while the system is running, which is preaty great. Here�s how:

1. Let say your physical disk is /dev/sda, you already have two partitions (/dev/sda1 and /dev/sda2) and want to extend the rest of the free space. fdisk /dev/sda and create a new partition /dev/sda3

2.� pvcreate /dev/sda3

3.��vgextend VolGroup00 /dev/sda3

4.�� lvextend /dev/VolGroup00/LogVol00 /dev/sda3

5.�� resize2fs /dev/VolGroup00/LogVol00

Now, asume that we want to reduce. This is a little bit tricky, you can not do it on the fly. You have to boot with a rescue cd (can be CentOS cd1 and type linux rescue at prompt).

1. lvm vgchange -a y

2. e2fsck -f /dev/VolGroup00/LogVol00

3. resize2fs -f /dev/VolGroup00/LogVol00 20G

4. lvm lvreduce -L10G /dev/VolGroup00/LogVol00

Happy resizing !