Sunday, 28 June 2015

Make password less ssh (script for passwordless ssh)


Make pass wordless ssh (script for password less ssh)


Writter: Anuj Borah
Email: anujborah1@gmail.com



#!/bin/bash
echo "Welcome!!! I am gonna make some passwordless ssh connection ...  coz i dont like passwords"
clear
echo "Gime me the ip of remote server u wana make password less ....."
read w
echo "Now givw me the any existing user of remote server ....."
read e
clear
echo "I will make sure that ur info is correct ....  "
ssh $e@$w mkdir -p .ssh
clear
echo "Now i gonna start my work ...  here u need to press "Enter" only when ask ..........."
ssh-keygen -t rsa
cd
cd .ssh
clear
echo "Just put the info (username and password) for the last time ...."
scp id_rsa.pub $e@$w:/home/$e/.ssh/authorized_keys
clear
echo "checking the passwordless connectivity.....Type "exit""
ssh $e@$w
clear
echo ":) . Thanks have a nice day !! see u on facebook `firefox https://m.facebook.com/Mr.Anuj2223`"

exit

Wednesday, 28 January 2015

how to share any folder of your pc over ftp or vsftp

How to share any folder of your PC over ftp or vs-ftp

say i need to  share /media/usb5/ftp folder over ftp ...

Follow the following steps:

As we know The default location on ftp is /home/user/.


* mkdir /media/usb5/ftp

now see when u do "ftp ip-of-ur-pc" from a another pc , u will have /home/user/ as default location .  so we will go  as follow.

* mount --bind /media/usb5/ftp /home/user/

and

* service vsftpd restart

dats all

put all the file u want to share over ftp on /media/usb5/ftp folder with proper
permission .

If u want to default location back ,

* umount /media/usb5/ftp

Writer: Anuj Borah
Email: anujborah1@gmail.com


Monday, 12 January 2015

solution for fstab wrongly configured

solution for  fstab wrongly configured .


Some day before i have faced a problem /etc/fstab wrongly configuration .
System was not booting .  I have tried with normal commands to edit the fstab file , but it was write protected. Finely i have got solution .  

Solution : It will work any of the version of linux .  ( Redhat , centos, fedora, ubuntu , debian etc)

(Well its not a script )




Give the root password .

type

mount -n -o remount,  rw /

and now you can edit the /etc/fstab file with vi editor .


dats all . :)


Name: Anuj Borah
Email: anujborah1@gmail.com


Sunday, 28 December 2014

script to install flash player on CentOS, Fedora, RedHat

script to install  flash player on CentOS, Fedora, RedHat


Writer: Anuj Borah
Email: anujborah1@gmail.com

#!/bin/bash
clear
if [ $UID -eq 0 ]
then
echo "Downloading the necessary file ....  wait"
sleep 3
wget "http://fpdownload.macromedia.com/get/flashplayer/pdc/11.2.202.425/install_flash_player_11_linux.x86_64.tar.gz"

clear
tar -zxvf install_flash_player_11_linux.x86_64.tar.gz

clear
cp libflashplayer.so /usr/lib64/mozilla/plugins/ > /dev/null
cp -r usr/* /us > /dev/null
echo "Configuration on the way... have patient..."

sleep 3

clear
echo "All Done , Restart firefox now ."

else
echo "&&&&&&This Script will run as root only ,  login as root and try $0  again. &&&&&&"
fi

Script to mount ntfs drives on Red Hat , CentOs And Fedora.

 Script to mount ntfs drives on Red Hat , CentOs   And Fedora.

Writter:Anuj Borah
Email: anujborah@gmail..com



#!/bin/bash
clear
echo -e "Wecome\nWriter:Anuj Borah\nEmail:anujborah1@gmail.com"
sleep 3
if [ $UID -eq 0 ]
then
rpm -q gcc &&  echo "OK Nice" || echo "gcc not installed u must install  gcc type 'yum install gcc' then try again"
sleep 3
wget "tuxera.com/opensource/ntfs-3g_ntfsprogs-2014.2.15.tgz"
clear
echo "Download in progress , wait "
sleep 3
tar -zxvf ntfs-3g_ntfsprogs-2014.2.15.tgz
cd ntfs-3g_ntfsprogs-2014.2.15
clear
chmod +x *
clear
./configure
make
make install
clear
echo "Looks like every thing gone fine.Now i will check it"
firefox borahshell.blogsopt.in
sleep 3
clear
echo "give me the drive to mount to your system"
read p
clear
echo "Given drive $p and the drive will be mounted to /media/usb"
sleep 3
clear
mkdir /media/usb >/dev/null
mount mount -t ntfs-3g $p  /media/usb
clear
echo "Congrats all done . Now u can access ntfs drive by typing cd /media/usb"
else
echo "&&&&&&This Script will run as root only ,  login as root and try $0  again. &&&&&&"
fi


Tuesday, 23 December 2014

Shell script that will allow live monitoring of Apache Server

This the script that will enable live monitoring of Apache Server Ex. Who is currently logged on to it.

It will be look like the following screen shot .



Note: This script will work for Ubuntu (All  versions) and Debian(All Version ) only. There is another script for Redhat , Centos and Fedora.


Writer: Anuj Borah
Email: anujborah1@gmail.com



#!/bin/bash
clear
Writer: Anuj Borah
Email: anujborah1@gmail.com
sleep 3
echo "This the script for apache server monitoring.(Press F5 to refress)"
sleep 3
if [ $UID -eq 0 ]
then
dpkg -l apache2 && echo "Congrats ,Apache is installed" || echo "Apache is not installed type (apt-get install apache2) to linstall apache"
sleep 3
a2enmod status > /dev/null
clear
echo "Give the ip address to which u want to associate for apache server monitoring " ; read p

echo "<IfModule mod_status.c>
    # Allow server status reports generated by mod_status,
    # with the URL of http://servername/server-status
    # Uncomment and change the "192.0.2.0/24" to allow access from other hosts.

    <Location /server-status>
        SetHandler server-status
        Require local
        Allow from 127.0.0.1 ::1 $p
        #Require ip 192.0.2.0/24
    </Location>

    # Keep track of extended status information for each request
    ExtendedStatus On

    # Determine if mod_status displays the first 63 characters of a request or
    # the last 63, assuming the request itself is greater than 63 chars.
    # Default: Off
    #SeeRequestTail On


    <IfModule mod_proxy.c>
        # Show Proxy LoadBalancer status in mod_status
        ProxyStatus On
    </IfModule>


</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet" > /etc/apache2/mods-enabled/status.conf

service apache2 restart > /dev/null

clear
echo "All Done. Now i will enable the system.(Press F5 to refress) "
sleep 3
firefox http://127.0.0.1:server-status

else
echo "&&&&&&This Script will run as root only ,  login as root and try $0  again. &&&&&&"
fi

Tuesday, 11 November 2014

script for interview perpose

Write a bash​ shell​ or perl script which does the following:

 - accepts a syslog file path, comma seperated list of service names and another argument which is a string (​this is an optional argument)
 - prints the count of logs of each service name on a separate line
 - If the optional string argument is provided, then searches for it in the logs of the provided service names and prints its count ​on a separate line.
 - prints usage if it is incorrect

 This was interview question for me .  Look how i have given the solution after 3 attempt :)



 Writer: Anuj Borah
Email: anujborah1@gmail.com



#!/bin/bash
clear
 echo -e "__________ Welcome____________\n"
if [ $# -eq 0 ]; then
echo "Please provide the ./script-name, file name and service-name (ex- ./script syslog CRON,CRON... critical )  "
fi
if [ $# -eq 2 ]; then
test -f $1
if [ $? -eq 0 ]
then
a=$1
oIFS="$IFS"; IFS=, ; set -- $2 ; IFS="$oIFS"
for i in "$@"; do
echo $i has the following count:
grep -o $i $a | wc -l
grep $i $a >> /tmp/1
done
fi
elif [ $# -eq 3 ]; then
echo -e "$1\n$2\n$3" >> /tmp/2
a=$1
oIFS="$IFS"; IFS=, ; set -- $2 ; IFS="$oIFS"
for i in "$@"; do
echo $i has the following count:
grep -o $i $a | wc -l
grep $i $a >> /tmp/1
done

b=`awk 'NR==3' /tmp/2`
echo  -e "\nThe over all count for $b is as follows:"
grep $b /tmp/1 | wc -l || echo "No such word" && echo "All Done"
rm /tmp/1 > /dev/null
rm /tmp/2 > /dev/null
else
echo "No such file"
fi



See the output



Popular Posts