Archive

Archive for the ‘Tools’ Category

Enabling Fail2ban

February 14th, 2016 No comments

Hundreds lines of log in wordpress show that, attackers are just trying passwords via xmlrpc.php. Add protection using the WP fail2ban plugin, inspired by the post here.

Categories: Tools Tags: ,

Enabing Pretty Permalinks

December 28th, 2015 No comments

Well.. long time no see. Just have some time to optimize the site for better analysis.

According to the official tutorial:
1. Enable mod_rewrite in apache2.

# sudo a2enmod rewrite

2. Enable FollowSymLinks option, which is default.
3. Enable FileInfo directives. Edit /etc/apache2/sites-available/yoursite.com.conf, add:

  <Directory /home/yourname/yoursite/>
    Require all granted
    AllowOverride FileInfo
  </Directory>

4. Restart apache:

# sudo service apache2 restart

Updated Dec 31, 2015:
Enabling mod_rewrite rewrites all requests including the one used by mod_status. To disable this, add a rule to the .htaccess file.

RewriteCond %{REQUEST_URI} !=/server-status

Then, change its user & group attributes to prevent overwriting from apache.

Categories: Tools Tags:

3 New Plugins Installed

July 8th, 2015 No comments

Just added another personal site for one of my friends. So another chance to speed up loading for my own site, from mainland china >.<

1. Disable google fonts: Remove Google Fonts References

2. Use local avatar: WP User Avatar

3. Use local emoji: WP Local Emoji (installed, but not activated.)

Categories: Tools Tags: ,

Setting up Serial Console on VirtualBox

April 7th, 2014 1 comment

I’m running Ubuntu 12.04 as host, with VirtualBox 4.2.22. This tutorial should cover guests including Windows XP, CentOS and Ubuntu.

1. Settings in VirtualBox

In the settings page, Check “Enable Serial Port”, set “Port Number” to “COM1”. This is the port number in the guest. If the guest is a Linux, COM1 is shown as /dev/ttyS0, and COM2 is shown as /dev/ttyS1.

Set “Port Mode” to “Host Pipe”, check “Create Pipe” and set “Port/File Path” to “/tmp/vbox”. Seems it utilizes a named pipe. These settings work even if the host does not have a physical serial device.

serial_console_1

2. Install minicom

# sudo apt-get install minicom
# sudo minicom -s

The second command setups minicom with an interactive menu. Select “Serial port setup”, and set “Serial Device” as “unix#/tmp/vbox”(without quotes). “Save setup as dfl” and “Exit from Minicom”.

3. Verity the serial device in guest

Now boot your Linux guest. Run the following command, and it should output something like:

# su
# stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
...

The guest here is CentOS5, and the serial device is /dev/ttyS0.

4. Communication via serial device

Start minicom on your host:

# minicom

Echo something from your guest and redirect to /dev/ttyS0. You host should get the message in minicom.

# echo "sent from rhel5 guest" > /dev/ttyS0

To read from the host, cat the device in guest so that you can do the input in minicom:

# cat /dev/ttyS0

serial_console_2

5. Kernel configuration

CentOS5 comes with grub1, /etc/grub.conf is modified directly to allow the boot information to also be sent to our serial device. The original boot entry looks like:

title CentOS (2.6.18-371.6.1.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-371.6.1.el5 ro root=LABEL=/
        initrd /boot/initrd-2.6.18-371.6.1.el5.img

Change to add console= parameter:

title CentOS (2.6.18-371.6.1.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-371.6.1.el5 ro root=LABEL=/ console=tty0 console=ttyS0,9600
        initrd /boot/initrd-2.6.18-371.6.1.el5.img

That’s all for CentOS 5/6. There’s no need to modify /etc/inittab or /etc/securetty file as required in ArchLinux. These OS will do it for you.

Now, reboot your guest CentOS. The boot information should now displayed in your minicom. Finally, it will provide you with a login shell.

serial_console_3
You can verify that there’s a new line added into /etc/inittab to enable getty(8) and execute a login shell:

co:2345:respawn:/sbin/agetty ttyS0 9600 vt100-nav

And ttyS0 is also added into /etc/securetty.

6. Ubuntu guest settings

Ubuntu 12.04 come with grub2. We do not modify /boot/grub/grub.cfg, we modify /etc/default/grub instead, so that the serial console parameters will remain even after you update your kernel. Open it, modify the following line to:

GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"

And update grub:

# sudo update-grub

One additional step for Ubuntu, is to enable getty(8) for serial console by your own. Ubuntu uses upstart init system, we need to create a file called /etc/init/ttyS0.conf containing the following:

# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc or RUNLEVEL=[12345]
stop on runlevel [!12345]

respawn
exec /sbin/getty -L 115200 ttyS0 vt102

Reboot you Ubuntu guest, and the serial device should work as it is with CentOS. More info, please refer to the official wiki.

7. Windows guest settings

The serial device shows as COM1 in Windows XP as previously set. With a simple echo and redirect, our host can receive the message.

serial_console_4

8. Windows as host

Settings of VirtualBox under Windows is almost the same as that under Linux. But we set “Port/File Path” to “\\.\pipe\vbox”, instead of “/tmp/vbox”. After the configuration of kernel and getty(8), we can use PuTTY to connect. Simply set “Connection type” to “Serial”, and “Serial line” to “\\.\pipe\vbox”.
serial_console_5

Categories: Tools Tags: ,

Installing Mac OSX 10.6 in VMware Player

August 21st, 2013 No comments

Macintosh really has a fantastic UI. I once installed OSX 10.3 successfully using pearpc, but it was awfully slow, since it need to emulate PowerPC via software layer. And now, I just successfully installed OSX 10.6 Snow Leopard in VMware player 5.0.2. The equivalent workstation version is 9.0.2. I tried virtualbox, but it just did not work. Now, please follow my steps:

1. Create a new VM and select the OS type as “FreeBSD”.

2. Close the VMware player. Open the *.vmx file find the line:

guestOS = "freebsd"

Change to:

guestOS = "darwin10"

Start VMware player again. The OS type is now set to “Mac OSX 10.6 Server”:

osx106_1

3. Modify VM: set Memory to 1G, check “Accelerate 3D Graphics”. Now, here’s the most _important_ step: Remove your existing hard disk, and add a new one, but choose SCSI as the virtual disk type. Change the CD/DVD device to also use SCSI type via the “Advanced” button. Without these steps, you will encounter the famous “still waiting for root device” error. Seems OSX cannot handle IDE devices correctly. 🙁

osx106_2

4. I used EmpireEFI v1085 to boot and install OSX 10.6, please find both images for your own. When EmpireEFI boots finishes, mount the OSX 10.6 image and press F5 to refresh. VMware player 5.0.2 supports *.dmg file directly, please select all files to find the image:

osx106_3

5. Here we go, just press enter and you will be booted into OSX installer:

osx106_4

6. If the disk drive doesn’t appear under “Select the disk where you want to Install Mac OSX”, go to menu Utility –> Disk Utilities and erase the whole disk:

osx106_5

7. The disk should now appear. You may want to customize the installation by clicking the button in left-bottom corner. Then let’s move on:

osx106_6

8. When finished, the system will reboot automatically. And it will fail. We must still use EmpireEFI to boot. But we select to boot OSX this time:

osx106_7

9. After some simple configuration, you will finally have your OSX desktop. Cheers!

osx106_8

Updated Aug 23:
The EmpireEFI did not work after I upgraded to 10.6.8. Kernel panic appeared like:

This symbol set has the following unresolved symbols:

I used iBoot 3.3 to replace EmpireEFI, and booted successfully.

osx106_9

You will have App Store(available in 10.6.6+) in your menu after upgrade. I also installed Xcode 3.2.6 which can still be downloaded from Apple. It requires 10.6.6 too.

Categories: Tools Tags: ,

Customizing Ubuntu Image with UCK

September 14th, 2012 No comments

UCK stands for Ubuntu Customization Kit: https://launchpad.net/uck

We can use PPA to install it:

# sudo apt-add-repository ppa:uck-team/uck-stable
# sudo apt-get update
# sudo apt-get install uck

And you’ll find it in under “System Tools” section of your menu. Follow the wizard to create your own Ubuntu image. It will extract your Ubuntu image, and also the squashfs on it. 5G free disk space is required under ~/tmp. The final customized image locates as ~/tmp/remaster-new-files/livecd.iso.

I tried to use a 10.04.4 image as base image. It ends with message:

You asked for a hybrid ISO but isohybrid command was not found.

Don’t worry. The final image is already created. isohybrid is in syslinux package 3.72 and later. But Ubuntu 10.04 has only 3.63.

Now you can use the image like the source image. Either burn it or use it to install from harddisk. I integrated all Chinese supports, codecs and some development tools. See screenshot of my livecd:

ubuntu_uck

Categories: Tools Tags:

Root Galaxy Nexus with Android 4.1 Jelly Bean

July 20th, 2012 No comments

Just tried to root my GSM Galaxy Nexus manually several days ago. I followed the instruments on the XDA forum here and here. File used are placed in my skydrive.

  1. Download root package (SuperSU-0.93-Busybox-1.20.2.zip)
  2. Download CWM (recovery-clockwork-5.5.0.2-maguro.img)
  3. Reboot into Fastboot Mode: Power off your device and (Power + Volume Up and Down)
  4. Unlock the bootloader if locked (fastboot oem unlock) then reboot into fastboot mode again
  5. Temporarily flash CWM (fastboot flash recovery recovery-clockwork-5.5.0.2-maguro.img)
  6. Boot into recovery (Press Volume Up twice until you see “Recovery mode” then press the Power button)
  7. Using CWM recovery, install SuperSU-0.93-Busybox-1.20.2.zip that you downloaded in step 1. The file should be placed in your /sdcard folder.
  8. Reboot into the OS
  9. You are now rooted
Categories: Tools Tags: ,

iOS 5 Device Support in Ubuntu Lucid 10.04

June 16th, 2012 No comments

Seems it’s quite easy to make my iPod touth 4 (iOS 5.0.1) work. 2 packages need update using PPA here. Or you can simply download them and install:

# wget http://ppa.launchpad.net/pmcenery/ppa/ubuntu/pool/main/u/usbmuxd/usbmuxd_1.0.7-1ubuntu1~lucid1_i386.deb
# wget http://ppa.launchpad.net/pmcenery/ppa/ubuntu/pool/main/u/usbmuxd/libusbmuxd1_1.0.7-1ubuntu1~lucid1_i386.deb
# sudo dpkg -i *.deb

Now your audios/videos in your iOS devices are recognized in Rhythmbox :).

Categories: Tools Tags: ,

Reset GNOME Keyring Password on Ubuntu

February 22nd, 2012 No comments

http://ubuntu-tutorials.com/2010/01/16/reset-gnome-keyring-password-on-ubuntu/

Just copy the solution here:

Method 1:
It is possible to clobber your keyring passphrase and settings from the Terminal. Open a terminal (Applications > Accessories > Terminal), and run the command:

# rm ~/.gnome2/keyrings/login.keyring

On older systems you may need to try:

# rm ~/.gnome2/keyrings/default.keyring

Method 2:
The second method bypasses the Terminal and uses the graphical interface strictly. To delete your current keyring, follow the steps below:

  1. Navigate to Applications > Accessories > Passwords and Encryption Keys
  2. Select the far-right tab “Passwords”
  3. Select your keyring
  4. Right-click and attempt “Change Password” or, if that doesn’t work, select “Delete”
Categories: Tools Tags:

Lyrics Tool in Linux Recommended

February 20th, 2012 No comments

http://code.google.com/p/osd-lyrics/

ubuntu_osdlyrics

I used to have lrcshow-x, but it seems to be hard to install and do not cache lyrics locally. From the osdlyrics download file list, use the 0.4.0 version for Ubuntu 10.04 (Lucid). Newer versions are broken in MPRIS2 protocol handling, see here.

Categories: Tools Tags: