How To Verify SSL Certificate From A Shell Prompt

How do I verify and diagnosis SSL certification installation from a Linux / UNIX shell prompt? How do I validate SSL Certificate installation and save hours of troubleshooting headaches without using a browser? How do I confirm I’ve the correct and working SSL certificates?

http://www.cyberciti.biz/faq/test-ssl-certificates-diagnosis-ssl-certificate/

Nginx Error_log Configuration

Nginx serves millions of applications on a daily basis, and those millions of apps generate errors. Guess what? So do yours. Some of them are critical, while others are just notices. The important thing here is to get access to those errors to debug and have a clear view of what’s happening with your web applications.

In this article, you will explore the Nginx error_log configuration and how Nginx handles the types of errors that can be logged into the files.

http://www.nginxtips.com/nginx-error_log-configuration/

Duplicati Backup Software

Duplicati is a backup client that securely stores encrypted, incremental, compressed backups on cloud storage services and remote file servers. It works with Amazon S3, Windows Live SkyDrive, Google Drive (Google Docs), Rackspace Cloud Files or WebDAV, SSH, FTP (and many more). Duplicati is open source and free.

Duplicati has built-in AES-256 encryption and backups can be signed using GNU Privacy Guard. A built-in scheduler makes sure that backups are always up-to-date. Last but not least, Duplicati provides various options and tweaks like filters, deletion rules, transfer and bandwidth options to run backups for specific purposes.

Reference and Download:
http://www.duplicati.com

Backup and Restore permissions in Linux

You can use getfacl and setfacl to take a backup of permissions from a directory and then restore those permissions back if required at a later date.

The following directory of /perms contains these permissions:

/perms/
|-- [-rw-r--r--] permfile1.txt
|-- [-rw-r--r--] permfile2.txt
|-- [drwxr-xr-x] subperm1
| |-- [-rwxr-xr-x] permfile1.txt
| `-- [-rw-r--r--] permfile2.txt
`-- [drwxr-xr-x] subperm2
|-- [-rw-r--r--] permfile1.txt
`-- [-rwxr-xr-x] permfile2.txt

To Backup this directory and sub-directory permissions you can run:

# getfacl -R /perms > perms_bu

The contents of the perms_bu file will contain all the permission details for both directories and files. Should any file or directory permissions be changed or modified in the future, we can restore as show below with the perms_bu file

To restore the permissions:

# setfacl --restore=perms_bu

NOTE: When you restore the permissions be sure you are in the relevant path area e.g. for the above example run the restore from the root area /

Reference:
Linux Man pages or http://linux.die.net/man/1/getfacl

 

Rootcheck

Rootcheck is an open source command line tool that looks for indicators of compromise on Linux or BSD systems. It tries to find known backdoors, kernel-level rootkits, malware and insecure configuration settings. It is included as part of OSSEC, but can also be executed separately from here as needed. If you suspect your server has been compromised it will certainly help with your investigation.

Install and run details can be found here: http://dcid.me/rootcheck

Also read this blog post titled “Investigating a Compromised Server with Rootcheck

 

Colorize log files with ccze tool

This is CCZE, a fast log colorizer written in C, intended to be a
drop-in replacement for colorize (http://colorize.raszi.hu).

CCZE is a robust and modular log colorizer with plugins for apm, exim, fetchmail, httpd, postfix, procmail, squid, syslog, ulogd, vsftpd, xferlog, and more.

Installation:

# yum install ccze (Red Hat/CentOS)
# apt-get install ccze (Debian/Ubuntu)

Usage:

tail -f -n 50 /var/log/syslog | ccze

Output is really nice as shown here:

blog-cczetool

 

 

 

 

 

Reference:
https://github.com/cornet/ccze
http://freecode.com/projects/ccze/

 

Put /tmp on tmpfs

On Dustin Kirkland’s blog http://blog.dustinkirkland.com/2016/01/data-driven-analysis-tmp-on-tmpfs.html he wrote up a piece on running /tmp on tmpfs and I’m sold on it!

He writes:
– Put /tmp on tmpfs and you’ll improve your Linux system’s I/O, reduce your carbon foot print and electricity usage, stretch the battery life of your laptop, extend the longevity of your SSDs, and provide stronger security.
– In fact, we should do that by default on Ubuntu servers and cloud images.
– Having tested 502 physical and virtual servers in production at Canonical, 96.6% of them could immediately fit all of /tmp in half of the free memory available and 99.2% could fit all of /tmp in (free memory + free swap).

The benefits of /tmp on tmpfs are:

  • Performance: reads, writes, and seeks are insanely fast in a tmpfs; as fast as accessing RAM
  • Security: data leaks to disk are prevented (especially when swap is disabled), and since /tmp is its own mount point, we should add the nosuid and nodev options (and motivated sysadmins could add noexec, if they desire).
  • Energy efficiency: disk wake-ups are avoided
  • Reliability: fewer NAND writes to SSD disks

To enable it is a simple:

$ echo "tmpfs /tmp tmpfs rw,nosuid,nodev" | sudo tee -a /etc/fstab
$ sudo reboot

More info at the link above

Collecting Ubuntu Linux System Information

For new computer or Laptop or server, I need to collect the information about its hardware. This is also useful when you need to replace a disk or memory with a vendor. In order to replace hardware you need all information in advance.

Display the system’s host name:

$ hostname

Display the system’s DNS domain name:

$ dnshostname

 

Find the system serial number, manufacturer of the system and model name:

$ sudo dmidecode -s system-serial-number
$ sudo dmidecode -s system-manufacturer
$ sudo dmidecode -s system-product-name
$ sudo dmidecode | more

OR use the lshw command:

# lshw | more
$ sudo lshw -short

Display information about installed hardware

$ sudo lsdev

Find the system CPU info

$ cat /proc/cpuinfo

Find the system main memory (RAM) info. Show statistics about memory usage on the system including total installed and used RAM:

$ less /proc/meminfo

Find the Ubuntu Linux distribution version and related information:

$ lsb_release -a

Find the system kernel architecture (32 bit or 64 bit):

$ uname -m
$ getconf LONG_BIT
$ arch

Show all installed disks and size:

# fdisk -l | grep '^Disk /dev'

Display SCSI devices (or hosts) and their attributes on Linux:

$ lsscsi

Find the system PCI devices information:

$ lspci
$ lspci -vt
$ lspci | grep -i 'something'
$ lspci -vvvn| less

Find the system USB devices information:

$ lsusb
$ lsusb -vt

Find the system Wireless devices information:

$ iwconfig
$ watch -n 1 cat /proc/net/wireless
$ wavemon

Find the system audio devices information:

$ lspci | grep -i audio

Display the system drivers (modules):

$ sudo lsmod
$ sudo modinfo {driver_name}
$ sudo modinfo kvm

Display the list of running services:
### SYS V ###

$ sudo service --status-all

OR
## UPSTART ##

$ sudo initctl list

Find out if service is enabled:
## UPSTART ##

$ sudo initctl status service-name
$ sudo initctl status smbd

OR
## SYS V

$ sudo service serviceName status
$ sudo service nginx status