Wednesday, February 15, 2012

Disable root login in Ubuntu – Avoid unexpected ‘OMG’ problems.

Recently I faced a huge issues in my production environment ,where ppl try to login as root to system which made system more unstable(Yes I know its in mess- super democracy server). As you know Ubuntu came with ‘Sudo’ concept which gives all the privilege’s that you want in systems. There for don not allow root user in your system especially in production. More details can be found in :

 Two steps to block any root logins :
1.      Disable Root user : 
sudo passwd -dl root

2.  Disable root login in ssh config:
vim /etc/ssh/sshd_config
PermitRootLogin no
And restart sshd -- > /etc/init.d/sshd restart

BTWAY: I was able to recover lost root password from a linux machine. Will update on that in future release .

Monday, February 6, 2012

Detect USB Flash Drivers in linux

Following Script Display possible USB devices attached to the system : Tested on Ubantu 10.04 LTS

#author sanjeewaF

for udi in $(/usr/bin/hal-find-by-capability --capability storage)
    device=$(hal-get-property --udi $udi --key block.device)
    vendor=$(hal-get-property --udi $udi --key storage.vendor)
    model=$(hal-get-property --udi $udi --key storage.model)

   if  [ `hal-get-property --udi $udi --key linux.sysfs_path | grep -i usb | wc -l` -gt 0 ]
           echo "Possible USB:"
           parent_udi=$(hal-find-by-property --key block.storage_device --string $udi)
           mount=$(hal-get-property --udi $parent_udi --key volume.mount_point)
           label=$(hal-get-property --udi $parent_udi --key volume.label)
            media_size=$(hal-get-property --udi $udi --key storage.removable.media_size)
           size=$(( media_size/(1000*1000*1000) ))
            printf "$vendor  $model  $device  $mount  $label "${size}GB" \n"