Wednesday, August 10, 2011

SSH login without password


First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):

a@A:~> ssh b@B mkdir -p .ssh
b@B's password:
Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:
From now on you can log into B as b from A as a without password:

a@A:~> ssh b@B hostname
B

Thursday, August 4, 2011

differential backup

when you run following command first you get full backup files.then other all running times you can get only updates...

tar -cz -g snapshot_file -f $dest/$archive_file $backup_files

changing destination is more important .using that you can get only updates for this backups..

:)

Tuesday, July 26, 2011

how to get backup in Linux server

for this problem i use shell script to get incremental and daily backups.In this cause i use cron tab for run that script at that time.

shell script 1 - daily backup(test.sh)


####################################



echo "Starting to get incremental backup"
date=`date +%Y%m%d`
rsync --delete -avh /home/kasun/Desktop/new /home/kasun/Desktop/back-$date

Long listing of files in $dest to check file sizes.
ls -lh $dest

echo "Full Backups_done.." | mail -s "incremental Done at kasun " kasunmanduraeng@gmail.com
sendmail -q
##############################################

test2.sh....full backup

###############################################
# What to backup.
backup_files="/home/kasun/Desktop/new"

# Where to backup to.
dest="/home/kasun/Desktop/test"

# Create archive filename.
day=$(date +%Y%m%d)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"
day1=$(date +%d)
yday1=$((day1-1))
date1=$(date +%Y%m)


remove="$hostname-$date1$yday1.tgz"
# Print start status message.
echo "Backing up $backup_files to $dest/$archive_file"
date
echo

# Backup the files using tar.
tar czf $dest/$archive_file $backup_files ###daily back up
#remove after 2 days backups

echo $dest/$archive_file $backup_files
rm $dest/$remove

# Print end status message.
echo
echo "Backup finished"
date


echo "Full Backups_done.." | mail -s "daily full Done at kasun " kasunmanduraeng@gmail.com
sendmail -q
##################################

after getting back receive notification mail.


Edit cron tab........

in command line type..


crontab -e

then edit crontab(you can edit /etc/crontab also)

00 00 * * * root /root/test.sh ##every hour ur incremental backup process running
00 00 00 * * root /root/test2.sh## every day for bacup running

Friday, April 8, 2011

shell scripts for CGI with Linux

program name:- test.sh , directory:/var/www/cgi-bin

#!/bin/sh
# test.sh
# Environment Variable
echo Content-Type: text/plain ; charset=ISO-8859-1
echo
pwd
ls -l
exit

save and run in web browser (http://localhost/cgi-bin/test3.sh) .out put show in following image
enjoy with CGI programing

Friday, April 1, 2011

Install and configure gns3 in linux(fedora)

First we'll have to install dependencies

[user@kasun ~]$ su

Password: (Type in your root password here)

[root@kasun /]# yum install python python-devel xorg-x11-proto-devel libXext-devel

[root@kasun /]# yum install gcc-c++

Now we'll download and install Qt4

[root@kasun /]#cd /tmp

[root@kasun tmp#wget http://ftp.uludag.org.tr/pub/source/2009/qt-x11-opensource-src-4.5.1.tar.gz

[root@kasun tmp]#tar xzf qt-x11-opensource-src-4.5.1.tar.gz

[root@kasun tmp]# cd qt-x11-opensource-src-4.5.1

[root@kasun qt-x11-opensource-src-4.5.1]#./configure -nomake examples -nomake demos -qt-gif -no-exceptions -debug -qt3support

[root@kasun qt-x11-opensource-src-4.5.1]#gmake <====This might take 2-3 hrs.

[root@kasun qt-x11-opensource-src-4.5.1]#gmake install <====Another 30 mins or so

[root@kasun qt-x11-opensource-src-4.5.1]#PATH=/usr/local/Trolltech/Qt-4.5.1/bin:$PATH

[root@kasun qt-x11-opensource-src-4.5.1]#export PATH


Next we'll install SIP

[root@kasun qt-x11-opensource-src-4.5.1]#cd ..

[root@kasun tmp]#wget http://ftp.uludag.org.tr/pub/source/2009/sip-4.8.1.tar.gz

[root@kasun tmp]#tar xzf sip-4.8.1.tar.gz

[root@kasun tmp]#cd sip-4.8.1

[root@kasun sip-4.8.1]#python configure.py

[root@kasun sip-4.8.1]#make

[root@kasun sip-4.8.1]#make install


Next we'll Install PyQt4

[root@kasun sip-4.8.1]#cd ..

[root@kasun tmp]#wget http://ftp.uludag.org.tr/pub/source/2009/PyQt-x11-gpl-4.5.2.tar.gz

[root@kasun tmp]#tar xzf PyQt-x11-gpl-4.5.2.tar.gz

[root@kasun tmp]#cd PyQt-x11-gpl-4.5.2

[root@kasun PyQt-x11-gpl-4.5.2]#python configure.py

[root@kasun PyQt-x11-gpl-4.5.2]#make <=== more time

[root@kasun PyQt-x11-gpl-4.5.2]#make install


We are done with compiling part, now lets download GNS3 source files

[root@kasun tmp]#cd /opt

[root@kasun opt]#wget http://space.dl.sourceforge.net/project/gns-3/GNS3/0.7.2/GNS3-0.7.2-src.tar.bz2

[root@kasun opt]#tar -xjvf GNS3-0.7.2-src.tar.bz2 && rm GNS3-0.7.2-src.tar.bz2

[root@kasun opt]#mv GNS3-0.7.2-src /opt/GNS3


Create the following directories:
These directories will be used by GNS3 – such as projects – where your working projects will be stored, cache, temp, IOS images, etc.

[root@kasun opt]#cd /opt/GNS3
[root@kasun GNS3]#mkdir Dynamips
[root@kasun GNS3]#mkdir IOS
[root@kasun GNS3]#mkdir Project
[root@kasun GNS3]#mkdir Cache
[root@kasun GNS3]#mkdir tmp
[root@kasun GNS3]#chmod o+rw -R ./Project
[root@kasun GNS3]#chmod o+rw -R ./tmp
[root@kasun GNS3]#chmod o+rw -R ./IOS

Download binary of dynamips and make it executable

[root@kasun GNS3]#cd Dynamips

[root@kasun Dynamips ]#wget http://www.ipflow.utc.fr/dynamips/dynamips-0.2.8-RC2-x86.bin

[root@kasun Dynamips ]#chmod +x ./dynamips-0.2.8-RC2-x86.bin



You can create a desktop shortcut by right-clicking on the desktop and select “Create Launcher..”, Name it GNS3 and in the command section type in

python "/opt/GNS3/gns3"

Double click to open GNS3 and we will edit the default settings. If you don’t want to use desktop icons you can create a launcher from your programs menu by right clicking on the Main Menu, selecting Edit Menu. Select New Item on the right and you will be presented with the same window where you type in the above. From there you can move the launcher into any menu section of your choice.

Fire up GNS3

* Go to edit | preferences and in the ‘Terminal command:’ section type in:
gnome-terminal -t %d -e 'telnet %h %p' > /dev/null 2>&1 &


* Under ‘Paths’ change the ‘Project directory:’ to
/opt/GNS3/Project
and the ‘IOS/PIX directory:’ to
/opt/GNS3/IOS

* Click on Dynamips tab on the left
For the ‘Executable path:’ type in
/opt/GNS3/Dynamips/dynamips-0.2.8-RC2-x86.bin

* Change the ‘Working directory:’ to
/opt/GNS3/tmp
Click on the Capture tab on the left

* For the ‘Working directory for capture files:’ change it to
/opt/GNS3/Project


woooow now you can rock with GNS 3 .....


Thursday, March 24, 2011

How to mount ntfs partition to redhat

1.Click on the "Applications" menu and choose "Terminal" from the "Accessories" group.
2.Type the command "su -" to become the root user. Enter the root password when prompted.
3.Add the "RPMforge" repository to your system--this allows your system to download and install NTFS support. Type the following commands:

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm

rpm -K rpmforge-release-0.5.1-1.el5.rf.i386.rpm

rpm -ivh rpmforge-release-0.5.1-1.el5.rf.i386.rpm

4.Install the ntfs-3g package--this provides NTFS support. Type the command "yum install fuse fuse-ntfs-3g" and answer "yes" if prompted to import an encryption key or to install packages.

5. Issue the "mount" command to mount the NTFS partition.

If your NTFS partition is accessible from device /dev/sda3 and you want the partition to appear on /mnt, use the command "mount /dev/sda3 /mnt."

Friday, September 10, 2010

how to install ssh serve in Ubuntu

OpenSSh is opensource ssh server in Linux.


Ubuntu SSHD Installation

Type the following two command to install both ssh client and server:
# sudo apt-get install openssh-server openssh-client

SSHD Configuration

To be frank your server is ready by default. Just test it from your home computer or from same system with the command:
# ssh localhost
OR
# ssh user@your-server-ip-address

How do I use ssh client?

Assuming that your server hostname is userver.kasun.com and username is kasun, you need to type the following command:
# ssh kasun@userver.kasun.com
To stop ssh server, enter:
# sudo /etc/init.d/ssh stop
To start sshs server, enter:
# sudo /etc/init.d/ssh start
To restart ssh server, enter:
# sudo /etc/init.d/ssh restart