option 1 # shred -n 7 -z /dev/sdb option 2 # dd if=/dev/urandom of=/dev/sdb bs=4096 count=7 # dd if=/dev/zero of=/dev/sdb bs=4096 count=7
Showing posts with label system administration. Show all posts
Showing posts with label system administration. Show all posts
Tuesday, October 11, 2011
how to securely wipe a drive in linux
Wednesday, August 31, 2011
Nagios - ERROR opening session: An empty privacy password was specified.
in Nagios® Core™ 3.2.3 i got this error when running checks with "check_snmp_load":
"ERROR opening session: An empty privacy password was specified."
on the command line, after executing this:
../libexec/snmp/check_snmp_load.pl -l readpriv -x xxxxxx -X xxxxxx -H hostname -w 3,3,2 -c 4,4,3 -T netsl
i got this:
Argument "v6.0.1" isn't numeric in numeric lt (<) at ./check_snmp_load.pl_old line 348.
Load : 0.00 0.00 0.00 : OK
I changed line 348 from:
my $resultat = (Net::SNMP->VERSION < 4) ?
to:
my $resultat = (Net::SNMP->VERSION lt 4) ?
..works
"ERROR opening session: An empty privacy password was specified."
on the command line, after executing this:
../libexec/snmp/check_snmp_load.pl -l readpriv -x xxxxxx -X xxxxxx -H hostname -w 3,3,2 -c 4,4,3 -T netsl
i got this:
Argument "v6.0.1" isn't numeric in numeric lt (<) at ./check_snmp_load.pl_old line 348.
Load : 0.00 0.00 0.00 : OK
I changed line 348 from:
my $resultat = (Net::SNMP->VERSION < 4) ?
to:
my $resultat = (Net::SNMP->VERSION lt 4) ?
..works
Wednesday, August 17, 2011
automatically bring up the openvpn client
# /etc/rc.local
echo 0 > /proc/sys/net/ipv4/conf/tun0/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
echo 1 > /proc/sys/net/ipv4/ip_forward
/usr/local/sbin/openvpn --config /etc/openvpn/client.conf --daemon &
#i use this to do all kinds of stuff...
echo 0 > /proc/sys/net/ipv4/conf/tun0/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
echo 1 > /proc/sys/net/ipv4/ip_forward
/usr/local/sbin/openvpn --config /etc/openvpn/client.conf --daemon &
#i use this to do all kinds of stuff...
Monday, August 15, 2011
Friday, August 12, 2011
compare packages between two RHEL systems
#generate package list on hostname1
rpm -qa --qf "%{NAME}\n" > hostname1.rpm.txt
cat ./hostname1.rpm.txt | sort | uniq > ./hostname1_final.rpm.txt
#generate package list on hostname2
rpm -qa --qf "%{NAME}\n" > hostname2.rpm.txt
cat ./hostname2.rpm.txt | sort | uniq > ./hostname2_final.rpm.txt
#you want the difference between systems - show diffs on the right and trim leading whitespace
sdiff ./hostname1.rpm.txt ./hostname2.rpm.txt | grep '>' | sed -e 's/^[> \t]*//'
#you want the difference between systems - show diffs on the left and trim trailing whitespace
sdiff ./hostname1.rpm.txt ./hostname2.rpm.txt | grep '<' | sed -e 's/[ \t<]*$//'
rpm -qa --qf "%{NAME}\n" > hostname1.rpm.txt
cat ./hostname1.rpm.txt | sort | uniq > ./hostname1_final.rpm.txt
#generate package list on hostname2
rpm -qa --qf "%{NAME}\n" > hostname2.rpm.txt
cat ./hostname2.rpm.txt | sort | uniq > ./hostname2_final.rpm.txt
#you want the difference between systems - show diffs on the right and trim leading whitespace
sdiff ./hostname1.rpm.txt ./hostname2.rpm.txt | grep '>' | sed -e 's/^[> \t]*//'
#you want the difference between systems - show diffs on the left and trim trailing whitespace
sdiff ./hostname1.rpm.txt ./hostname2.rpm.txt | grep '<' | sed -e 's/[ \t<]*$//'
Wednesday, August 3, 2011
clearing a mail queue
#sendmail
sendmail -qS -v subdomain.test.com
#postfix
for f in ` mailq |egrep subdomain.test.com -B 2 |grep ^[A-Z0-9]|awk '{print $1}'` ; do postsuper -d $f; done
sendmail -qS -v subdomain.test.com
#postfix
for f in ` mailq |egrep subdomain.test.com -B 2 |grep ^[A-Z0-9]|awk '{print $1}'` ; do postsuper -d $f; done
Monday, July 25, 2011
mdadm notes
mdadm --remove /dev/md0 /dev/sdb
#pull disk, replace with new one
# you have to fail a disk before you remove it
# however, if the system wont release the raid partner, you need to slide the offending disks out and boot off a good disk.
#here you can review the layout
[root@host~]# fdisk -l /dev/sda
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 16 128488+ fd Linux raid autodetect
/dev/sdb2 17 1291 10241437+ fd Linux raid autodetect
/dev/sdb3 1292 2566 10241437+ 83 Linux
/dev/sdb4 2567 30401 223584637+ 5 Extended
/dev/sdb5 2567 2827 2096451 fd Linux raid autodetect
/dev/sdb6 2828 2860 265041 fd Linux raid autodetect
/dev/sdb7 2861 30401 221223051 fd Linux raid autodetect
#review the descriptions of the disks
-----------
[root@host ~]# sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors
/dev/sda1 : start= 63, size= 256977, Id=fd, bootable
/dev/sda2 : start= 257040, size= 20482875, Id=fd
/dev/sda3 : start= 20739915, size= 20482875, Id=83
/dev/sda4 : start= 41222790, size=449113140, Id= 5
/dev/sda5 : start= 41222853, size= 4192902, Id=fd
/dev/sda6 : start= 45415818, size= 530082, Id=fd
/dev/sda7 : start= 45945963, size=444389967, Id=fd
[root@host ~]# sfdisk -d /dev/sdb
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
No partitions found
-----------
#this command is similar to `sfdisk -l`, but you can use it to copy the layout to the new replacement disk
#its destructive to sdb, be sure you know what you're doing. read man page, right? :)
-----------
[root@host~]# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 30522 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 * 63 257039 256977 fd Linux raid autodetect
/dev/sdb2 257040 20739914 20482875 fd Linux raid autodetect
/dev/sdb3 20739915 41222789 20482875 83 Linux
/dev/sdb4 41222790 490335929 449113140 5 Extended
/dev/sdb5 41222853 45415754 4192902 fd Linux raid autodetect
/dev/sdb6 45415818 45945899 530082 fd Linux raid autodetect
/dev/sdb7 45945963 490335929 444389967 fd Linux raid autodetect
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@host~]# sfdisk -d /dev/sdb
# partition table of /dev/sdb
unit: sectors
/dev/sdb1 : start= 63, size= 256977, Id=fd, bootable
/dev/sdb2 : start= 257040, size= 20482875, Id=fd
/dev/sdb3 : start= 20739915, size= 20482875, Id=83
/dev/sdb4 : start= 41222790, size=449113140, Id= 5
/dev/sdb5 : start= 41222853, size= 4192902, Id=fd
/dev/sdb6 : start= 45415818, size= 530082, Id=fd
/dev/sdb7 : start= 45945963, size=444389967, Id=fd
-----------
#check the status of the set
cat /proc/mdstat
#now, add the partition slices back to the set
mdadm --add /dev/md0 /dev/sdb1
mdadm --add /dev/md1 /dev/sdb5
mdadm --add /dev/md3 /dev/sdb6
mdadm --add /dev/md4 /dev/sdb7
mdadm --add /dev/md2 /dev/sdb2
#review
mdadm --detail /dev/md0
#review progress
cat /proc/mdstat
healthy output:
[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
128384 blocks [2/2] [UU]
md1 : active raid1 sda5[0] sdb5[1]
2096384 blocks [2/2] [UU]
md3 : active raid1 sda6[0] sdb6[1]
264960 blocks [2/2] [UU]
md4 : active raid1 sda7[0] sdb7[1]
221222976 blocks [2/2] [UU]
md2 : active raid1 sda2[0] sdb2[1]
10241344 blocks [2/2] [UU]
unused devices:
UNhealthy output:
[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1]
128384 blocks [2/2] [_U]
md1 : active raid1 sdb5[1]
2096384 blocks [2/2] [_U]
md3 : active raid1 sdb6[1]
264960 blocks [2/2] [_U]
md4 : active raid1 sdb7[1]
221222976 blocks [2/2] [_U]
md2 : active raid1 sdb2[1]
10241344 blocks [2/2] [_U]
unused devices:
#have a nice day
--------------------------------------------------------
[root@somehost ~]# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.03
Creation Time : Sat Oct 31 03:08:47 2009
Raid Level : raid1
Array Size : 128384 (125.40 MiB 131.47 MB)
Device Size : 128384 (125.40 MiB 131.47 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Mon Jul 25 04:48:26 2011
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : xxxxxx:xxxxxxxx:xxxxxxx:dd7a13a5
Events : 0.74
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
--------------------------------------------------------
nagios check: check_by_ssh!"sudo /bin/cat /proc/mdstat | grep _ /proc/mdstat -c | grep 0 -c
#pull disk, replace with new one
# you have to fail a disk before you remove it
# however, if the system wont release the raid partner, you need to slide the offending disks out and boot off a good disk.
#here you can review the layout
[root@host~]# fdisk -l /dev/sda
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 16 128488+ fd Linux raid autodetect
/dev/sdb2 17 1291 10241437+ fd Linux raid autodetect
/dev/sdb3 1292 2566 10241437+ 83 Linux
/dev/sdb4 2567 30401 223584637+ 5 Extended
/dev/sdb5 2567 2827 2096451 fd Linux raid autodetect
/dev/sdb6 2828 2860 265041 fd Linux raid autodetect
/dev/sdb7 2861 30401 221223051 fd Linux raid autodetect
#review the descriptions of the disks
-----------
[root@host ~]# sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors
/dev/sda1 : start= 63, size= 256977, Id=fd, bootable
/dev/sda2 : start= 257040, size= 20482875, Id=fd
/dev/sda3 : start= 20739915, size= 20482875, Id=83
/dev/sda4 : start= 41222790, size=449113140, Id= 5
/dev/sda5 : start= 41222853, size= 4192902, Id=fd
/dev/sda6 : start= 45415818, size= 530082, Id=fd
/dev/sda7 : start= 45945963, size=444389967, Id=fd
[root@host ~]# sfdisk -d /dev/sdb
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
No partitions found
-----------
#this command is similar to `sfdisk -l`, but you can use it to copy the layout to the new replacement disk
#its destructive to sdb, be sure you know what you're doing. read man page, right? :)
-----------
[root@host~]# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 30522 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 * 63 257039 256977 fd Linux raid autodetect
/dev/sdb2 257040 20739914 20482875 fd Linux raid autodetect
/dev/sdb3 20739915 41222789 20482875 83 Linux
/dev/sdb4 41222790 490335929 449113140 5 Extended
/dev/sdb5 41222853 45415754 4192902 fd Linux raid autodetect
/dev/sdb6 45415818 45945899 530082 fd Linux raid autodetect
/dev/sdb7 45945963 490335929 444389967 fd Linux raid autodetect
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@host~]# sfdisk -d /dev/sdb
# partition table of /dev/sdb
unit: sectors
/dev/sdb1 : start= 63, size= 256977, Id=fd, bootable
/dev/sdb2 : start= 257040, size= 20482875, Id=fd
/dev/sdb3 : start= 20739915, size= 20482875, Id=83
/dev/sdb4 : start= 41222790, size=449113140, Id= 5
/dev/sdb5 : start= 41222853, size= 4192902, Id=fd
/dev/sdb6 : start= 45415818, size= 530082, Id=fd
/dev/sdb7 : start= 45945963, size=444389967, Id=fd
-----------
#check the status of the set
cat /proc/mdstat
#now, add the partition slices back to the set
mdadm --add /dev/md0 /dev/sdb1
mdadm --add /dev/md1 /dev/sdb5
mdadm --add /dev/md3 /dev/sdb6
mdadm --add /dev/md4 /dev/sdb7
mdadm --add /dev/md2 /dev/sdb2
#review
mdadm --detail /dev/md0
#review progress
cat /proc/mdstat
healthy output:
[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
128384 blocks [2/2] [UU]
md1 : active raid1 sda5[0] sdb5[1]
2096384 blocks [2/2] [UU]
md3 : active raid1 sda6[0] sdb6[1]
264960 blocks [2/2] [UU]
md4 : active raid1 sda7[0] sdb7[1]
221222976 blocks [2/2] [UU]
md2 : active raid1 sda2[0] sdb2[1]
10241344 blocks [2/2] [UU]
unused devices:
UNhealthy output:
[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1]
128384 blocks [2/2] [_U]
md1 : active raid1 sdb5[1]
2096384 blocks [2/2] [_U]
md3 : active raid1 sdb6[1]
264960 blocks [2/2] [_U]
md4 : active raid1 sdb7[1]
221222976 blocks [2/2] [_U]
md2 : active raid1 sdb2[1]
10241344 blocks [2/2] [_U]
unused devices:
#have a nice day
--------------------------------------------------------
[root@somehost ~]# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.03
Creation Time : Sat Oct 31 03:08:47 2009
Raid Level : raid1
Array Size : 128384 (125.40 MiB 131.47 MB)
Device Size : 128384 (125.40 MiB 131.47 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Mon Jul 25 04:48:26 2011
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : xxxxxx:xxxxxxxx:xxxxxxx:dd7a13a5
Events : 0.74
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
--------------------------------------------------------
nagios check: check_by_ssh!"sudo /bin/cat /proc/mdstat | grep _ /proc/mdstat -c | grep 0 -c
Labels:
linux,
mdadm,
mdstat,
nagios,
system administration
Thursday, July 21, 2011
mail alert when script is finished
echo y | ./deploy.sh -s xxxx -f '/root/xxxxx.tgz' && mail -s "deployment complete on `hostname`" me@overthere.com < /dev/null
Monday, July 18, 2011
logrotate script
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
create a list of all packages
#!/bin/sh
/bin/rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm\n' 2>&1 \
| /bin/sort > /var/log/rpmpkgs
The idea would be to take a sha1 hash of this file and then check it periodically to be sure that the package list has not changed.
/bin/rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm\n' 2>&1 \
| /bin/sort > /var/log/rpmpkgs
The idea would be to take a sha1 hash of this file and then check it periodically to be sure that the package list has not changed.
Labels:
linux,
system administration,
system hardening
Wednesday, June 22, 2011
oracle linux links
http://www.oracle.com/us/technologies/linux/index.htm
http://www.oracle.com/us/technologies/linux/unbreakable-enterprise-kernel-ds-173416.pdf
http://www.oracle.com/us/technologies/linux/ubl-edison-066204.pdf
http://public-yum.oracle.com/
http://www.oracle.com/us/technologies/linux/unbreakable-enterprise-kernel-ds-173416.pdf
http://www.oracle.com/us/technologies/linux/ubl-edison-066204.pdf
http://public-yum.oracle.com/
Labels:
linux,
oracle,
security,
system administration,
system hardening
Monday, June 13, 2011
Wednesday, March 23, 2011
unable to build ports in OpenBSD 4.8 - SOLVED
From root's .profile, comment this out:
...
if [ -x /usr/bin/tset ]; then
if [ X"$XTERM_VERSION" = X"" ]; then
eval `/usr/bin/tset -sQ '-munknown:?vt220' $TERM`
else
eval `/usr/bin/tset -IsQ '-munknown:?vt220' $TERM`
fi
fi
...
and add this:
export TERM=vt100
...
if [ -x /usr/bin/tset ]; then
if [ X"$XTERM_VERSION" = X"" ]; then
eval `/usr/bin/tset -sQ '-munknown:?vt220' $TERM`
else
eval `/usr/bin/tset -IsQ '-munknown:?vt220' $TERM`
fi
fi
...
and add this:
export TERM=vt100
Thursday, June 17, 2010
Tuesday, May 18, 2010
convert vmdk from thick to thin
vmkfstools -i /vmfs/volumes/datastore1/somehost/somehost.vmdk /vmfs/volumes/datastore1/somehost/somehost-thin.vmdk -d 'thin' -a lsilogic
# adjust vmx and away you go.
# adjust vmx and away you go.
Labels:
linux,
system administration,
system engineering,
virtualization,
vmware
Tuesday, March 23, 2010
generate reasonable passwords at the commmand line
cat /dev/urandom| tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?='|fold -w 12| head -n 4| grep -i '[!@#$%^&*()_+{}|:<>?=]'
generate strong random passwords at the command line
cat /dev/urandom| tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?='|fold -w 12| head -n 4| grep -i '[!@#$%^&*()_+{}|:<>?=]'
Tuesday, February 2, 2010
grantaccess.sh
#!/bin/sh
if [ $# -lt 4 ]; then
echo "syntax: $0 host user time 'reason'"
echo "e.g. grantaccess.sh '0am jan 10' 'reason why'"
exit 1
fi
ssh $1 usermod -U $2
ssh $1 chage -E -1 $2
echo "ssh $1 usermod -L $2 " | at $3
echo "ssh $1 skill -KILL -u $2" | at $3
echo `logname` granted $2 access on $1 till $3 - Reason Given:"$4" | mail -s "Access granted"
if [ $# -lt 4 ]; then
echo "syntax: $0 host user time 'reason'"
echo "e.g. grantaccess.sh
exit 1
fi
ssh $1 usermod -U $2
ssh $1 chage -E -1 $2
echo "ssh $1 usermod -L $2 " | at $3
echo "ssh $1 skill -KILL -u $2" | at $3
echo `logname` granted $2 access on $1 till $3 - Reason Given:"$4" | mail -s "Access granted"
Labels:
bash,
linux,
shell scripting,
system administration
Sunday, December 6, 2009
allow tftp under selinux
For RHEL5:
# audit2allow -a -M mytftp
# semodule -i mytftp.pp
# service xinetd restart
# audit2allow -a -M mytftp
# semodule -i mytftp.pp
# service xinetd restart
Labels:
linux,
pxe,
security,
selinux,
system administration
Subscribe to:
Posts (Atom)