Showing posts with label How-To. Show all posts
Showing posts with label How-To. Show all posts

Thursday, November 24, 2011

Linux Kernel Compilation

How to: Compile Linux kernel

Compiling Cutom Kernel is Fun activity. Serially Its own advantages and disadvantages.

However, Beginner / sometimes admin find it difficult to compile Linux kernel. Compilation needs to be understand before typing any command.

Here is the steps by step Information:

Step # 1 Download the Latest Linux kernel tar ball.
#cd /home/shihora/
#wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2

Step # 2 Extract tar file
# tar -xjvf linux-x.y.z.tar.bz2 -C /usr/src
# cd /usr/src

Step # 3 Configure kernel
Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system.
# yum install gcc
Now you can start kernel configuration by typing any one of the command:

# make menuconfig - Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
# make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop
For example make menuconfig command launches following screen:
# make menuconfig
You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.

Step # 4 Compile kernel
Start compiling to create a compressed kernel image, enter:
#make
Start compiling to kernel modules:
#make modules
Install kernel modules (become a root user, use su command):
#su -
#make modules_install

Step # 5 Install kernel
So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
# make install
It will install three files into /boot directory as well as modification to your kernel grub configuration file:
System.map-x.y.z
config-x.y.z
vmlinuz-x.y.z

Step # 6: Create an initrd image
Type the following command at a shell prompt:
# cd /boot
# mkinitrd -o initrd.img-x.y.z x.y.z
initrd images contains device driver which needed to load rest of the operating system later on.

Step # 7 Modify Grub configuration file - /boot/grub/menu.lst
Open below file using vi:
# vi /boot/grub/menu.lst
title           Debian GNU/Linux, kernel 2.6.25 Default
root            (hd0,0)
kernel          /boot/vmlinuz root=/dev/hdb1 ro
initrd          /boot/initrd.img-2.6.25
Remember to setup correct root=/dev/hdXX device. Save and close the file.

Step # 8 : Reboot computer and boot into your new kernel
# reboot
Thats it Guys .. Isn't it fun activity :)

How to Setup Password-less SSH Using Public - Private Keys

This HOWTO is a step-by-step guide for configuring and using password-less SSH service on Linux systems and is intended for a technical audience only.

The term “password-less” means that SSH authentication is carried out by using public and private keys. Using public/private key authentication with SSH enables SSH logins without requiring passwords interactively and this is known as SSH key authentication.

You need to generate a pair of public/private keys on your client system. In order to generate public/private keys on your client system use the ssh-keygen program within a terminal as shown below.

[shihora@linuxhungrymind ~]$ ssh-keygen -t dsaGenerating public/private dsa key pair.
Enter file in which to save the key (/home/shihora/.ssh/id_dsa):
Created directory '/home/shihora/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/shihora/.ssh/id_dsa.
Your public key has been saved in /home/shihora/.ssh/id_dsa.pub.
The key fingerprint is:
D2:0e: ad: 54:e7:c2: 2e: 51:cb: cd: 7b: 68:db: 19:d3: 6e
shihora@linuxhungrymind

After you have created the public/private key pairs on your client machine, you need to copy the newly created public key to the server.

scp ~shihora/.ssh/id_dsa.pub  username@AnotherLinuxHungryMindServer:~username/.ssh/authorized_keys2

cat id_dsa.pub >> authorized_keys2

Certainly, you don’t want normal system users to alter the server’s authorized_keys2 file.

$ chmod 600 authorized_keys

After performing these operations you are done! Your server is ready to accept SSH connections from your client without requesting a password.

PAM PassPhrase Policy Implementation

Here are the step by step information:

To make every user on system choose strong passwords, in order to minimize hacking risks, one can implement the passphrase policy using below instructions.

Download “pam_passwdqc” module from given link.

FTP the downloaded file “pam_passwdqc-1.0.2.tar.gz” to linux server in any directory of your choice.

Unzip and untar the same. It will generate in “pam_passwdqc-1.0.2” directory.

Enter into that directory and execute following commands.

make
make install

This will generate the “pam_passwdqc.so” binary file and copy the same into /lib/security.

Change directory to /etc/pam.d and backup the original “system-auth” file.

Open “system-auth” file using vi editor and uncomment following line.

password    required      /lib/security/$ISA/pam_cracklib.so retry=3 type=

And insert following line in place of old line.

password    required      /lib/security/$ISA/pam_passwdqc.so