Upgrading OpenSSL

This one works for me on upgrading openssl.

1. Check your openssl version

# openssl version

OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

2. Download latest version of openssl

http://www.openssl.org/source/

or you may command

wget http://www.openssl.org/source/openssl-1.0.0d.tar.gz

3. Extract openssl-1.0.0d.tar.gz

Go to openssl-1.0.0d directory

# make clean
# ./config shared –prefix=/usr –openssldir=/usr/local/openssl
# make && make test
# make install

4. Done

5. Check the if you you have the latest version

# openssl version

OpenSSL 1.0.0d 8 Feb 2011

Enjoy….. ^__^

Delete user and directory

This script check the user if available if yes will prompt to delete the user and the directory.

#***********************************************************************

#!/bin/bash
#Script by Jeffrey Dante

#Check User if available

if [ $(id -u) -eq 0 ]; then
echo “Checking user $1″
cat /etc/passwd | awk -F: ‘{print $1}’ | grep -w $1
if [ $? -eq 0 ]; then

#Check User Disk Usage
LETTER=`/bin/echo $1 | /bin/awk ‘BEGIN{FS=””}{print $1}’`
DU=/usr/bin/du
echo “Disk Usage:”
$DU -msh /mnt/emaildata/$LETTER/$1/Maildir | awk ‘{print $1}’

while true;
do
read -p “Do you wish to delete this user $1 ? ”  yn
case $yn in
[Yy]* ) userdel $1; rm -r /mnt/emaildata/$LETTER/$1; echo “User $1 has been deleted”; exit;;
[Nn]* ) exit;;
* ) echo “Please answer yes or no.”;;
esac
done

exit 1

else
echo “$1 does not exists!”
fi

else
echo “Only root may delete a user”
exit 2
fi

#***********************************************************************

Script to add user and alias

I have seen similar script like this, I just added some arguments to make it suffice.

#**************************************************************************

#!/bin/bash
# Script to add a user with password and alias
# Jeffrey Dante

ADDUSER=/usr/sbin/adduser

if [ $(id -u) -eq 0 ]; then
read -p “Enter username : ” username
read -p “Enter email address: ” email
read -s -p “Enter password : ” password
egrep “^$username” /etc/passwd >/dev/null
egrep “^$email” /etc/aliases >/dev/null
if [ $? -eq 0 ]; then
echo “$username already exists!”
echo “$email already exist!”
echo “Make it sure that you do not have desame username and emaill address!”
exit 1
else
pass=$(perl -e ‘print crypt($ARGV[0], “password”)’ $password)
$ADDUSER -s /sbin/nologin -m -p $pass $username -G 100 $1
echo -e “$email:\t$username” >> /etc/aliases
echo -e “$email” >> /usr/files/addresses.txt
[ $? -eq 0 ] && echo “User has been added to system!” || echo “Failed to add a user!”

fi
else
echo “Only root may add a user to the system”
exit 2
fi
#**************************************************************************

Check User Script

I have created check user script to list the username, email alias, and the disk usage of the user. I hope this will give you some ideas preparing your own check user script.

#***********************************************************************
#!/bin/bash
#Script by Jeffrey Dante
#Check User if available
#List the email alias
#Show the directory usage

if [ $(id -u) -eq 0 ]; then
cat /etc/passwd | awk -F: ‘{print $1}’ | grep -w $1
if [ $? -eq 0 ]; then

# email: username
cat /etc/aliases | grep -w $1 | awk -F: ‘{print $1}’

# Check User Disk Usage

LETTER=`/bin/echo $1 | /bin/awk ‘BEGIN{FS=””}{print $1}’`
DU=/usr/bin/du
echo “Disk Usage:”
$DU -msh /mnt/emaildata/$LETTER/$1/Maildir | awk ‘{print $1}’

exit 1

else
echo “$1 does not exists!”
fi

else
echo “User verification Done!”
exit 2
fi

#***********************************************************************

Output should look like this
user
email/s
usage

[root@test.com jedscripts]# ./usercheck.sh jepdante
jepdante
jeffrey.dante@test.com
jeffrey_dante@test.com
Disk Usage:
55M

Installing openssl

To install openssl you can just do

yum install openssl

Or to update or do it manually:

1. check version
[root@test ]# openssl version
OpenSSL 0.9.7a Feb 19 2003

or

[root@test ]# openssl
OpenSSL> version
OpenSSL 0.9.7a Feb 19 2003

2. download latest openssl
3. extract

tar -zxvf openssl-1.0.0d.tar.gz

4. go to directory

cd openssl-1.0.0d

5. configure

./config shared –prefix=/usr –openssldir=/usr/local/openssl
make && make test
make install

6. if ask perl 5

yum install perl-DBI