create htpasswd entry and print to stdout

Create htpasswd entry and print to stdout:

$ sudo apt install apache2-utils # Optional

$ htpasswd -n $USERNAME
New password: 
Re-type new password: 
$USERNAME:<Password Hash>

Linux performance analysis

Brendan Gregg is the Linux performance god. Use the information in this link to find out what ways there are for performacne analysis.
This link is shows the more sophisticated way and encourages to dig deeper for optimizing your system. If you're in a hurry look at Linux Performance Analysis in 60,000 Milliseconds

puppet variable variable name

example

We want to make the following firewall rule to be applyable to different network interfaces (for e.g. different environments) with just one variable:

firewall { "010-reject-port":
  ensure      => present,
  dport       => [ 80 ],
  destination => $::ipaddress_eth0,
  proto       => 'tcp',
  action      => 'drop',
  iniface     => 'eth0',
}

We can create a $firewall_interface variable and apply it to iniface but how can we ensure that the correct ipaddress factof the corresponding interface is used for `destina...

Bash: Find out the exit codes of all piped commands

Bash stores the exitcodestatus of piped commands in the environment variable PIPESTATUS

So you can just echo ${PIPESTATUS[@]} to get them all.

13:52:30 ✔ claus:~$ ps ax | grep /usr/bin/ruby
13205 pts/20   S+     0:00 grep --color=auto /usr/bin/ruby


13:52:43 ✔ claus:~$ echo ${PIPESTATUS[@]}
0 0

PIPESTATUS is an array, so you can get the exitcode of an specific command (first pipe):

13:54:20 ✔ claus:~$ echo ${PIPESTATUS[1]}
0

get debug output for puppetmaster running with passenger

If you need the debug output of the puppetmaster running with passenger you have to uncomment this setting in the config.ru:

#ARGV << "--debug"

If you don't know where your config.ru is, check the Apache DocumentRoot. It's in /path/to/DocumentRoot/../config.ru. For example if your DocumentRoot is /etc/puppet/rack/public/ the config.ru is in /etc/puppet/rack/config.ru.

Exim: investigating frozen messages in the mailqueue

Investigate why mails are frozen

The exim documentation says:

Freezing occurs when a bounce message encounters a permanent failure because the sender address of the original message that caused the bounce is invalid, so the bounce cannot be delivered. This is probably the most common case, but there are also other conditions that cause freezing, and frozen messages are not always bounce messages.

By default, frozen bounce messages will b...

swaks - Swiss Army Knife SMTP, the all-purpose smtp transaction tester

swaks is a very nice tool to test SMTP. For the most linux distributions you can easily install it with your package management system.

This example send an email from from@example.com to to@example.com via the server mail23.example.com with the user from@example.com and password mysupersecurepasswordyouneverget for authentication and require the connection to use STARTTLS.

$ swaks -tls --to to@example.com --from from@example.com --auth-user from@example.com  --server mail23.example....

Change / Update SSL certificate for Amazon Elastic Load Balancer with AWS Command Line Interface

  1. Install and configure the AWS Command Line Interface

  2. Show existing certificates to test if the AWS Cli is working:

    $ aws iam list-server-certificates
    {
      "ServerCertificateMetadataList": [
          {
              "Path": "/", 
              "Arn": "arn:aws:iam::5xxxxxxxxxxx:server-certificate/www.example.com-201307-201407", 
              "ServerCertificateId": "AXXXXXXXXXXXXXXXXXXXX", 
              "ServerCertificateName": "www.example.com-201210-201310", 
     ...
    

Fix "A client error (MalformedCertificate) occurred: Invalid Private Key." at AWS SSL Certificate upload

I'm creating certificate requests with this command:

openssl req -new -out www.example.com.csr -keyout www.example.com.key -newkey rsa:2048 -nodes

When I try to upload the certificate to AWS IAM I get this error:

$ aws iam upload-server-certificate --server-certificate-name www.example.com-2013010-2014010 --certificate-body www.example.com.crt --private-key www.example.com.key --certificate-chain www.example.com.ca-bundle 
A client error (MalformedCertificate) occurred: Invalid Public Key Certificate.

That's because o...

Create swap space on Linux

Create a 1 GB file to swap to (we have sufficient space on / on this machine. Use a different partition if necessary)

sudo dd if=/dev/zero of=/var/swapfile bs=1M count=1024

If you prefer 2GB swap, chose count=2048, 4GB: count=4096

Change permissions of swap file:

sudo chmod 0600 /var/swapfile

Set up swap file and enable it:

sudo mkswap /var/swapfile
sudo swapon /var/swapfile

You should see your swap space now:

thomas@machine:~$ free -m
              total       used       free     shared    buffers...

Run multiple Redis servers on Ubuntu

This is a way to run multiple redis server on one ubuntu server.

These steps you have to do only once:

  • Adjust init script

Change some Variables.
From this:

DAEMON_ARGS=/etc/redis/redis.conf
NAME=redis-server
DESC=redis-server
PIDFILE=/var/run/redis.pid

to this:

NAME=`basename ${0}`
DAEMON_ARGS=/etc/redis/${NAME}.conf
DESC=${NAME}
PIDFILE=/var/run/${NAME}.pid
  • Move redis configuration
    ^
    mv /etc/redis/redis.conf /etc/redis/redis-server.conf

These steps y...