Some times when creating bulk users, admins are forced to create complex passwords. But how to do it? How many you can set manually? Let me put it in this way. For one or two users we can think for a random password and assign to them. But if its 100 users? Naaa.. I cannot think for 100 passwds.
So leave this job to Linux to create random passwords.
you use below command to generate random passwords
< /dev/urandom tr -dc A-Na-n1-9_ head -c8
This will just generate random 8 lenght password
For example :
See just typing the above command will generate a random password
root@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8
57fg67gKroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8
FN8ahe8broot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8
eLhLLNCGroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8
FK3CC9GNroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8
cA8H24Mlroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8
9eDL39I_root@ps6061:~#
Here is a script written by me to automate entire 20 user account creation.
#!/bin/bash
#Author:Surendra Kumar Anne
#Purpose:To automate user creation
#Date/Time:29-01-2010.19:10
mkdir -p /home/admin/useraccounts
for (( i=0; i<=20; i++ ))
do
useradd user$i
< /dev/urandom tr -dc A-Na-n1-9_ head -c8 > /tmp/passwd.txt
cat /tmp/passwd.txt passwd --stdin user$i
echo -e "Username:user$i" > /home/admin/useraccounts/user$i
echo -e "password:" >> /home/admin/useraccounts/user$i
cat /tmp/passwd.txt >> /home/admin/useraccounts/user$i
done
rm -rf /tmp/passwd.txt
Note : When password generating I have just created a password which will not contain o(small ooo), O(capital OO), 0(zero). This is to remove confusions for users. Some times user will get confusion when using these characters. If you want all the characters from a to z, A to Z, and 0-9 just use below code.
< /dev/urandom tr -dc A-Za-z0-9_ head -c8
How To Generate Randum Password
0 comments 2/07/2010 05:18:00 AM Posted by Meghana M BhombhoreLabels: Basic-Security
How To Use IPtables to Block ICMP (Internet Control Message Protocol) Requests?
0 comments 11/23/2009 05:30:00 AM Posted by Surendra Kumar AnneLabels: Basic-Security, Network Monitoring, Security
#ping target-machine
If this is succeed they will come to a conclusion that system is up and they can go forward and they can do DDOS attacks or try to find some other open ports using NMAP command.
Code :
#nmap target-machine
So if you are exposing a machine to outer world from your network, first disable incoming ping requests to your machine as follows.
So this can be done by two ways through IPtables
#service iptables save
#service iptables restart
#iptables –L
How to allow icmp ping request in case you want them,First we have to remove the rule which we created for blocking the icmp ping.
#iptables –D INPUT –p icmp --icmp-type echo-request –j DROP
Then execute the following commands
#iptables –A INPUT –p icmp --icmp-type echo-request –j ACCEPT
#service iptables save
#service iptables restart
Some points to be noted
What are the methods used by hackers using this ICMP ping?
Though these are old denial-of-service attack (DoS attack), worth to learn them
Ping flood
Smurf attack
Ping to death
SNORT(IDS/IPS) Configuration and Implemenation
0 comments 11/19/2009 10:48:00 PM Posted by Surendra Kumar AnneLabels: Advanced Servers, Basic-Security, Network Monitoring, Security
libpcap-1.0.0.tar.gz
pcre-8.00.tar.gz
libnet-1.0.2a.tar.gz (This is optional package if you want SMB popup alerts on window’s machines.)
snort-2.8.5.1.tar.gz
acid-0.9.6b23.tar.gz
#tar xvfz packagename.tar.gz
#cd ../libnet-1.0.2a
#./configure
#make
#make check
#make install
How To Take The Backup Of MBR(Master Boot Recorder)
2 comments 11/13/2009 07:53:00 AM Posted by Meghana M BhombhoreLabels: Administration, Basic-Security, Basics, Boot Troubleshooting, How-To's
1.How to take the backup and restore MBR? Why do you require to take the backup of your MBR?
Ans : MBR (Master Boot Recorder) is a vital part of your hard disk which contains booting information, without it its difficult to boot the system. Suppose you have windows and Linux duel boot on your machine and as you know windows is more prone to virus attacks. So it’s always better to backup your MBR to be in safe place.
2. How to take backup of your MBR?
Ans : Using dd command (dataset definition). Here are the steps to take backup of you MBR and keep it in safe place to restore your system if it get corrupted.
#dd if=/dev/hdx of=/safe/location bs=512 count=1
Let me explain the above command how it will work.
“If” in the command is nothing but to specify Input File, here we are specifying our input file as hard disk(if the hard disk is /dev/hda it is primary master, so for general purpose I given 'x'). “of” in the command is nothing but to specify Output File, here we are specifying our output file as /safe/location. Then “bs” this is nothing but block size to write in to hard disk. And then “count” nothing but how many times you want to write date this many block sizes. Here in this example count=1 that means first 512 bytes of the hard disk is copied to the specified location.
3.How to restore the MBR?
#dd if=/safe/location of=/dev/hdx bs=512 count=1
Note : Please replace “hdx” with your hard disk name.
This is bit complex, Is there any other way to restore MBR?
Yes, if you have Linux or Windows bootable CD, we can easily restore your MBR if you forgot to take backup(And this method is very much easy to do restoration of MBR when compared to previous method).
Method1 : With Redhat Linux bootable CD.
For this you have to boot your system to rescue mode, then mount your file system to rescue mode and execute below command to restore your MBR
#grub-install /dev/hdx
Note : Please replace hdx with your hard disk name. After that you just reboot your system. Your system will be live and working.
Method2 : With Windows XP bootable CD.
Step1 : Boot the system with XP bootable cd
Step2 : Press f8 to go to repair mode in Windows
Step3 : Once you got the c drive prompt just type below command
Fixmbr
This command will fix the MBR record.
Some FAQ’s
1. What is the MBR size?
Ans : MBR size is just 512 bytes.
2.What MBR conations?
Ans : Mainly MBR can be divided in two parts
a.Boot loader information block(which is of 448 bytes)
b. Partition table information(which is of just 64 bytes)
3.How many partition we can create on a hard disk?
Ans : Totally we can create four partitions as below
a.Four primary parathions.
b.Three primary and one extended partition.
c.Two primary and one extended parathion.
d.One primary and one extended parathion.
Note : In extended parathion we can create logical partitions up to 24 in number.
4.Why we cannot create more then 4 partition as mention above?
Ans : In MBR, the partition table info is just stored in 64 bytes, and one parathion information to store in MBR requires 16 bytes of space. So at most you can create only 4 partitions as mention above.
Please Comment your thoughts regarding this post:-)
How To Use VNSTAT To Monitor Bandwidth Usage.
0 comments 9/09/2009 09:04:00 AM Posted by Surendra Kumar AnneLabels: Basic-Security, Network Monitoring, Security
This tool can give you full details about how much bandwidth used on the basics of,
Per month.
Per week.
Per day.
Per hour.
Per second.
Even we can see live traffic. This is awesome tool .
So all the tools will not only have advantages but also disadvantages, here are they:
Before configuring vnstat, one thing we have to keep in mind that vnstat is a aggregating tool which is required to run at regular intervals to monitor network bandwidth. So by default when we install vnstat a cron job is created at /etc/cron.d folder.
Step1 : installing vnstat
#rpm –ivh vnstat-1.6-2.fc9.i386.rpm
Step2 : Configuring vnstat.
Vi /etc/cron.d/vnstat
Step3 : Specifying which interface to monitor
#vnstat –I interfacename
Example :
Type1 : For live traffic
#vmstat –l
Type2 :For monitoring traffic per second
#vmstat –tr 5
Type3 : For hourly
#vmstat –h
Example :
Type4:For dialy
#vmstat –d
Type5 : For weekly
#vmstat –w
Example :
10 Commandments !! U like it for sure!!
0 comments 6/23/2009 03:56:00 AM Posted by Surendra Kumar AnneLabels: Basic-Security, Boot Troubleshooting, Desktop, Disk Troubleshooting
This is a guest post by Praveen
10 COMMANDMENTS !! U LIKE IT FOR SURE !!=>1 People are illogical, unreasonable, and self-centered. Love them anyway.
=>2 If you do good, people will accuse you of selfish, ulterior motives. Do good anyway.
=>3 If you are successful, you will win false friends and true enemies. Succeed anyway.
=>4 The good you do today, will be forgotten tomorrow. Do good anyway.
=>5 Honesty and frankness make you vulnerable. Be honest and frank anyway.
=>6 The smallest men and women with the smallest minds can shoot down the biggest men and women with the biggest ideas. Think big anyway.
=>7 People favor underdogs, but follow only top dogs. Fight for a few underdogs anyway.
=>8 What you spend years building may be destroyed overnight. Build anyway.
=>9 People really need help, but may attack you if you do help them. Help people anyway.
=>10 Give the world the best you have and you’ll get kicked in the teeth. Give the world the best you have anyway.
Disabling SELinux
0 comments 5/28/2009 08:42:00 PM Posted by Surendra Kumar AnneLabels: Basic-Security, Security, SELinux
Some basics of SELinux :
How to disable SElinux?
SElinux is a security feature which was shipped with RHEL5, it is much secure than any other security priviously such as PAM and Initd
Here we are going to see some basics of SElinux.
Step1:Seeing whether SELinux is enabled or not ?
#getenforce
Step2:To see SELinux status in elaborated way you can use sestatus
#sestatus
SElinux status : enabled
SELinux mount : /selinux
Current mode : enforcing
Mode from config file : enforcing
Policy version : 21
Policy from config file : targeted
From the above output we can see that SElinux is enabled and its in enforced mode.
and to see detailed status you can use -b option, this will give which service are SElinux enabled and which services are disabled.
setenforce
/etc/grub.conf and /etc/selinux/config
Step3:disabling SElinux
We can do it in two ways
1)Perminant way : edit /etc/selinux/config
change the status from enable to disable and selinux type from strict to targeted, after changes are made we have to restart, if the server's are in production and don't want to restart the server follow the temporary way of disabling it.
2)Temporary way : echo 0 > /selinux/enforceFor your info if you want to enable it again, try below commandecho 1 > /selinux/enforce.
Selinux is a vast subject and can not deal in one post, see for my other posts regarding Selinux.


