Page 2 of 9

import and export GPG keys

list keys

list all keys currently in keyring:

gpg --list-keys


and to import private and public keys in binary or ASCII format:

gpg --import xyz.key


To export your private key in ASCII format, e.g. to send it via E-Mail:

gpg --export-secret-key --armor you@dom.tld > private.key

To export your public key, again in ASCII format:

gpg --export --armor you@dom.tld > public.key

If you don’t need it in ASCII format use for the private:

gpg --export-secret-key you@dom.tld > private.key

and the public:

gpg --export you@dom.tld > public.key

make git use vim and vimdiff

I like git, vim and vimdiff a lot! Here’s how you configure git to use vim as editor and vimdiff as merge tool:

git config --global merge.tool vimdiff
git config --global core.editor vim

enable SELinux on a Debian DO droplet


Sometimes I have a natural attraction to things making my life more complicated. I could have just installed CentOS. Or rented a dedicated server. Or stopped using SELinux. But I wanted it all. So I’d like to show you how you can install Debian 7 on a DigitalOcean droplet and have SELinux enabled.

The problem is that at DO the kernel comes from outside (KVM) and you cannot manipulate it nor it’s parameters. But you can use kexec to replace the kernel as soon as you’re in control.

Before you begin:

  • I assume a freshly installed Debian 7 here (tested on 64bit version)
  • you should take a backup before proceeding!

Okay, get all the updates and install the required software

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install selinux-basics selinux-policy-default auditd kexec-tools

Run selinux-activate, it modifies grub (no matter here), PAM and touches /.autorelabel:

$ sudo selinux-activate

Then, edit the file /etc/init.d/rcS and put the following in front of exec /etc/init.d/rc S

if grep -v kexeced /proc/cmdline ;then
      kexec -l /vmlinuz --initrd=/initrd.img --command-line="$(cat /proc/cmdline) selinux=1 security=selinux kexeced" && kexec -e

If this is done, you’re ready to reboot!

$ sudo reboot

You can add some extra time for the reboot as it has to relabel all the files for the first time.

When rebooted, check the SELinux status with:

$ sestatus

Happy labeling :)

bash variables magic


I often find myself searching for a, say, left() or mid() function when coding bash. Somehow my subconscious mind seems to know I’m doing too much in bash and therefore tends to forget things like a simple left() in bash. So I note them here. Lets hope I don’t forget where I wrote that down…

len() in bash

$ var='Hello, World!'
$ echo "${#var}"

left() in bash

$ var='Hello, World!'
$ echo "${var:0:5}"

right() in bash

$ var='Hello, World!'
$ echo "${var:7:${#var}}"
#or a litte more dynamic.. (the 6 most right chars)
echo "${var:$((${#var}-6)):${#var}}"

mid() in bash

$ var='Hello, World!'
$ echo "${var:4:4}"
o, W

string replace first in bash (substitute)

$ var='Hello, World!'
$ echo "${var/o/a}"
Hella, World!

string replace all in bash (substitute)

$ var='Hello, World!'
$ echo "${var//o/a}"
Hella, Warld!

Did I miss one?

week planner sheets

week planner

This is some off line stuff for once: I created a set of sheets to plan my week. I figured this may be useful for others as well, so here are the downloads:

weekplan business English

Wochenplan Geschäftlich Deutsch

weekplan private English

Wochenplan Privat Deutsch

If you have any suggestion to make them more useful to you, please let me know!

© 2017 netmess

Theme by Anders NorenUp ↑