加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

如何安全清除Linux服务器的内容?(1)

发布时间:2016-11-21 22:33:24 所属栏目:PHP教程 来源:网络整理
导读:副标题#e# 人们常常在谈论托管服务器或云服务器所带来的便利,但如果这些设备已经该寿终正寝,大家会如何处理?当然,我们可以联系设备商,让他们负责报废工作,但这实际上很难保证其中的数据安全地被加以清除。如果不具备对设备的物理访问能力,他们很难将
   #!/bin/bash

#

# This script will absolutely kill a RHEL/CentOS/Fedora server. Use with extreme caution.

# Tested with several CentOS/RHEL versions only. Run as root user.

# 10.20.11 Paul Venezia (pvenezia@pvenezia.com)

#

zeroscript="/var/ramdisk/zeroscript.sh"

echo "*******************************************************************

** This will permanently kill this Linux system and erase every **

** local disk and filesystem. In other words, you better be **

** REALLY REALLY SURE you want to do this on this system. **

*******************************************************************"

echo -n "Are you absolutely sure you want to do this? [yes|no]: "; read yn

if [ -z $yn ] || [ $yn != "yes" ]; then

echo "Aborting"

exit 1

fi

echo -n "How many zeroing passes? "; read zeropass

if [ -z $zeropass ] || [ $zeropass -lt 1 ]; then

echo "Invalid number of passes specified. Aborting."

exit 1

fi

echo -n "Automatically shutdown? [yes|no] "; read asd

echo "Okay, here we go..."

echo "Making and populating ramdisk (512MB)..."

mkdir -p /var/ramdisk

mount -t tmpfs none /var/ramdisk -o size=512m # You may need to adjust this depending on the amount of RAM in the box

mkdir -p /var/ramdisk/var/run

for f in dev bin lib lib64 sbin etc; do

cp -pr /$f /var/ramdisk

done

cp -pr /var/run /var/ramdisk/var

echo "Stopping services, it's probably safe to ignore any errors..."

for s in httpd acpid anacron atd auditd autofs avahi-daemon bluetooth cpuspeed crond cups firstboot gpm haldaemon hidd hplip irqbalance iscsi iscsid kudzu lm_sensors lvm2-monitor mcstrans mdmonitor messagebus microcode_ctl netfs nfslock pcscd portmap rawdevices readahead_early restorecond rpcgssd rpcidmapd sendmail smartd sshd syslog vmware-tools xfs yum-updatesd; do

service $s stop

done

echo "Placing zeroing script..."

echo "#!/bin/bash" > $zeroscript

for i in `fdisk -l | grep Disk | awk '{print$2}' | sed -e s/:// | grep -v /dev/md`; do

DU=$DU" "$i

DSK=`basename $i`

BLKS=$((`grep -w $DSK /proc/partitions | awk '{print$3}'` * 2)) # account for 512/1k blocksizes

BS=512

echo "echo "Zeroing $i (dd if=/dev/zero of=$i bs=$BS count=$BLKS) ..."" >> $zeroscript

for (( c=1; c<=$zeropass; c++ )); do

echo "echo "Pass $c..."" >> $zeroscript

echo "dd if=/dev/zero of=$i bs=$BS count=$BLKS" >> $zeroscript

done

echo "dd if=/dev/zero of=$i bs=512 count=1" >> $zeroscript # Just to make sure

done

echo "echo "Disk(s)$DU have been zeroed $zeropass times"" >> $zeroscript

if [ $asd = 'yes' ]; then

echo "echo "Shutting down..."" >> $zeroscript

echo "sleep 5 && /sbin/poweroff -n -d -f" >> $zeroscript

fi

chmod +x $zeroscript

echo "Turning off swap..." && swapoff -a

echo "Entering chroot..."

chroot /var/ramdisk /`basename $zeroscript`

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读