Posts

Showing posts from December, 2013

Quickest way to setup - KEY-BASED AUTHENTICATION: LINUX

For example, we gonna setup key-based authentication from server 192.168.x.y to 192.168.x.z ( we will use this auth for root uesr ) 1). Create SSH-Kegen Keys on – 192.168.x.y [root@192.168.x.y~] # ssh-keygen -t rsa 2). Create .ssh Directory on – 192.168.x.z # ssh root@192.168.x.z mkdir -p .ssh The authenticity of host '192.168.x.z (192.168.x.z)' can't be established. RSA key fingerprint is 3x:x7:a4:e5:af:89:c5:dx:b1:3c: 9d:xx:66:47:03:xx. Are you sure you want to continue connecting (yes/no)?  "press yes" 3). Upload Generated Public Keys to – 192.168.x.z # cat .ssh/id_rsa.pub | ssh root@192.168.x.z 'cat >> .ssh/authorized_keys' 4). Set Permissions on – 192.168.x.z # ssh root@192.168.x.z "chmod 700 .ssh; chmod 640 .ssh/authorized_keys" 5). Now you can login 192.168.x.z without password: [root@192.168.x.y~] # ssh root@192.168.x.z Last login: xxxxxxxxxxxxxxxxxxxxxx from 'last login

Backup and Restore of LINUX System Disk using "dd" command:

Backup and Restore of LINUX System Disk using "dd" command: creating disk1: # dd if=/dev/zero of=disk1 bs=1024000 count=2048 # mkdir d1 # mkfs.ext3 disk1 # mount disk1 d1 // It will end with error, so try, # mount -o loop disk1 d1 creating disk2: # dd if=/dev/zero of=disk2 bs=1024000 count=2048 #mkfs.ext3 disk2 # mkdir d2 # mount -o loop disk2 d2 # df -h -----  result will be, We can also use conv=notrunc,noerror options with "dd" command , - The notrunc conversion option means do not truncate the output file — that is, if the output file already exists, just replace the specified bytes and leave the rest of the output file alone. - Noerror means to keep going if there is an error. Dd normally terminates on any I/O error. to confirm this, # losetup -a /dev/loop0: [fd00]:142387 (/root/disk1) /dev/loop1: [fd00]:142390 (/root/disk2) copy some file into d1 for example: # wget http://ip

SHELL SCRIPT to generate random PASSWORD and CAPTCHA

Image
1). create a file named "password.sh"   #!/bin/bash while : do     clear     cat<<EOF                 ===================                 PASSWORD GENERATOR:                 -------------------             Enter the (P)assword length             Enter the (C)aptcha length                       (Q)uit                 ------------------- EOF     read -n1 -s     case "$REPLY" in     "E")     echo -e -n "\n\t: "     read b     a=$(tr -dc "A-Za-z0-9~!@#$%^&*-_" < /dev/urandom | head -c$b)     echo -e "\n\n\t\t$a"     ;;     "C")     echo -e -n "\n\t: "     read b     echo -e "\n\n\t\t" `/usr/bin/shuf -i 1-$b -z`     ;;     "Q")  exit 0                    ;;     "q")  echo "case sensitive!!"   ;;     "c")  echo "case sensitive!!"   ;;     "e")  echo "case sensitiv