linux

Mail Server Fingerprint

This is useful when you need the fingerprint to identify via TLS Get the raw certificate: echo Q | openssl s_client -connect mail.example.com:443 Copy and paste the scribble from —–BEGIN CERTIFICATE—– to —–END CERTIFICATE—– to a file called cert.pem. Including —–BEGIN CERTIFICATE—– as first and —–END CERTIFICATE—– as last line. Generate the SHA1 fingerprint by issuing following command: openssl x509 -in cert.pem -sha1 -noout -fingerprint

ssh authorization

Create a public ssh key, if you haven’t one already. Look at ~/.ssh. If you see a file named id_dsa.pub then you obviously already have a public key. If not, simply create one. ssh-keygen -t dsa ItemMake sure your .ssh dir is 700: chmod 700 ~/.ssh Get your public ssh key on the server you want to login automatically. scp ~/.ssh/id_dsa.pub remoteuser@remoteserver.com: Append the contents of your public key to the ~/.

HowTo install Google Earth on Debian

The Google Earth .DEB still depends on ia32-libs, but ia32-libs has been removed as part of the transition to multiarch, so it won’t install. Steps Download the 64-bit google earth .deb file from http://www.google.com/earth mkdir earth dpkg-deb -R google-earth*.deb earth edit the file earth/DEBIAN/control and replace the Depends line as shown below dpkg-deb -b earth earth.deb dpkg -i earth.deb apt-get install -f Replace Depends: lsb-core (>= 3.2), ia32-libs with

Self-Signed SSL Certificate

Note: This is a slighltly modified reprint from http://www.akadia.com Overview The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process. Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions.

Log Rotate

Simple: Create following file Change the MAXSIZE & LOGDIR (see file) Add a cron job Create following file: nano /var/www/log/logrotate.sh #!/bin/bash MAXSIZE=1024 LOGDIR=/var/www/log/ if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi cd $LOGDIR for FILENAME in *.log; do SIZE=$(du -b $FILENAME | cut -f 1) if(($SIZE>$MAXSIZE)); then TIMESTAMP=`date +%Y%m%d` NEWFILENAME=$FILENAME.$TIMESTAMP mv $FILENAME $NEWFILENAME touch $FILENAME chown www-data.

Network Safety Restart Bash Script

If you ever work on a remote servers network settings then this script may safe you from having to call support, and waiting on them. When started/executed it Sleeps first for 1 hour Then it renames the ”/etc/network/interfaces” file by adding the current time stamp to the end of the file It renames a file called ”/etc/network/interfaces.org” to ”/etc/network/interfaces” And finally it restarts the server. It also warns you a couple minutes before it does all that so you can terminate the program.

Linux bash history

Have you ever executed something on the linux shell and didn’t remember later how it was done? Well if you remember just part of it you can search for it: history | grep -i "[search string]"

msmtp install, config and test

Why have more then one mail server? Or why even have a mail server at all, if you can use gmail? Well there are many reasons to have at leased one mail server, but having one on each server doesn’t make sense at all. I tried both ssmtp and msmtp, and decided on msmtp. msmtp is an SMTP client. In the default mode, it transmits a mail to an SMTP server, which takes care of further delivery.

git branch on bash line

This little code, if placed in to your ~/.bash_profile file will reveal what git branch you are working on. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/(1)/' } if [[ $EUID -ne 0 ]]; then PS1="w$(parse_git_branch) $ " fi

Linux backround process

Running as background process with nohub nohup scp & > nohup.out 2 > &1 nohup scp -r -p root@www.example.com:/var/www/ /var/www/ & >nohup.out 2>&1 nohup scp -r -p root@www.example.com:/var/www/logs /var/www/ & >nohup.out 2>&1