Destroy all content of the disk (shred)

Since a couple of years there is a brilliant tool included in Debian/Ubuntu distro’s: shred

This tool will write random stuff on your harddisk which makes it harder to recover.

There are some nice options to write multiple times over the previous data.

This is something I use:

shred -n2 -v -z /dev/sde

-n2: This will write 2 times over the previous data
-v: Verbose, so you can monitor the process
-z: Zero all previous writes out to hide the shred.
/dev/sde: Your device you want to erase, replace with your own!

Of course with very expensive hardware there are some parts recoverable, but for normal use I think it’s fine.

Use at your own risk!

Create SSH banner per user

I Wanted to show information after logging in on a server (with SSH) specific for a certain user.

For example I have a local user with the username “admin”.

Put in the /etc/ssh/sshd_config the following line:

Match user admin
        Banner /etc/banner_admin

Restart the SSH daemon:

service sshd restart

Now after the user “admin” logs in (after the user enters the password) the user sees the banner you created in /etc/banner_admin

Systemtime in Nagios logs to human readable timestamps

Normally Nagios logs it’s command in Unix time so results from checks looks like this:

[1401179967] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;vsphere;DISK SPACE;1401179966
[1401179967] SERVICE ALERT: vsphere;DISK SPACE;OK;SOFT;2;C:\ Label: Serial Number ac58719b: 59%used(12035MB/20466MB) (<90%) : OK
[1401179986] EXTERNAL COMMAND: ENABLE_SVC_NOTIFICATIONS;vsphere;DISK SPACE

However this can be converted with a simple Perl script to a “normal” time/date format:

# perl -pe 's/(\d+)/localtime($1)/e' /var/log/nagios/nagios.log (or whatever your path is)

The result is now this:

[Tue May 27 10:39:27 2014] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;vsphere;DISK SPACE;1401179966
[Tue May 27 10:39:27 2014] SERVICE ALERT: vsphere;DISK SPACE;OK;SOFT;2;C:\ Label:  Serial Number ac56519b: 59%used(12035MB/20466MB) (<90%) : OK
[Tue May 27 10:39:46 2014] EXTERNAL COMMAND: ENABLE_SVC_NOTIFICATIONS;vsphere;DISK SPACE

Try it out 🙂