Archive for the ·


· Category...

SPF and DKIM on Postfix

Comments Off

A recent post by Jody Ribton laments the fact that DIY mail servers are having a hard time not getting blocked or rejected in today’s email landscape. The ensuing Slashdot discussion dissected the problem, and came up with a few good pieces of advice also seen on this digitalocean guide:

  • Make sure the server is not an open mail relay.
  • Verify that the sender and server IP addresses are not blacklisted.
  • Apply a Fully Qualified Domain Name (FQDN) and the same host name as the PTR record.
  • Set a Sender Policy Framework (SPF) DNS record.
  • Configure DomainKeys Identified Mail (DKIM) on the sending server and DNS.

Sender Policy Framework (SPF)

“Sender Policy Framework (SPF) is a simple email-validation system designed to detect email spoofing by providing a mechanism to allow receiving mail exchangers to check that incoming mail from a domain comes from a host authorized by that domain’s administrators”. [Wikipedia]. It is configured through a special TXT DNS record, and further setup on the sending part is not required.

This guide outlines the parameters, and the easiest way to get started is actually this Microsoft provided online wizard. Given a domain, it will guide you through the settings and present you with the DNS record to add at the end. If the domain already has a SPF record, it will verify it, and also take the current settings into account through the steps.

DomainKeys Identified Mail (DKIM) on Postfix

DKIM offers similar email spoofing protection, but also offers simple content signing. From Wikipedia: “DomainKeys Identified Mail (DKIM) is an email validation system designed to detect email spoofing by providing a mechanism to allow receiving mail exchangers to check that incoming mail from a domain is authorized by that domain’s administrators and that the email (including attachments) has not been modified during transport. A digital signature included with the message can be validated by the recipient using the signer’s public key published in the DNS.”

Configuration is quite straight forward on Postfix, and this guide shows a typical setup and some common pitfalls. If the same email server caters for multiple domains, an alternative configuration is required. This guide covers those details. Another DNS TXT record on the domain is also required. Finally, once the setup is complete, this tool can be used to verify the DNS record.

Verify the configuration

For both SPF and DKIM, the setup can also be verified by sending an email to In addition, an email can be sent to any Gmail account, and by viewing the original message and headers, an extra Authentication-Results header can be seen. See the last guide for further details.



Comments Off

Manual wifi config in Debian

Comments Off

Most modern GUI based distros handle setup and management of Wifi connections very well these days. However, sometimes you need to go the way of the command line. The following outlines the basics in Debian, plus some useful commands.

First, the Wifi device I had laying around was a Realtek based USB dongle similar to this. The driver for that is in the non-free repository, so I added the parts in bold to my /etc/apt/sources.list

deb wheezy main contrib non-free
deb wheezy-updates main contrib non-free

I could then install the driver:
apt-get update
apt-get install firmware-realtek

There are two config files to handle: The basic network configuration (/etc/network/interfaces), which also includes wired networks and the loopback, and the WPA wifi specific configuration (/etc/wpa_supplicant/wpa_supplicant.conf). Although it is also possible to specify wifi parameters in the network interfaces file, it is better handled by the wpa because then you can configure settings for multiple networks (e.g. home and work) as seen below.

/etc/network/interfaces contains the following:

# The loopback network interface
auto lo
iface lo inet loopback

# Wired ethernet
auto eth0
iface eth0 inet dhcp

# The primary network interface
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
      wpa-driver nl80211
      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

The loopback lo interface is configured, a wired eth0 port, and the wlan0 wifi. All networks are set to come up automatically, the last two use DHCP to get their address, and the Realtek nl80211 driver is specified as well as a reference to the WPA Supplicant config.

/etc/wpa_supplicant/wpa_supplicant.conf contains:


    psk="wifi passphrase"


Here two networks are configured: A home network with WPA encryption and its passphrase, and an open network for work.

To bring the wifi network up, simply run the following. If iterating on the configuration, it’s has to be stopped first.

ifdown wlan0 && ifup wlan0

Useful commands
Other useful commands while debugging this include:

For general network configuration and status:



For listing all available networks and their parameters. This works even before you have connected to a specific one, so it’s a good test to see if the wifi device is even working:
iwlist wlan0 scan

For starting the wpa supplicant manually and checking the wifi configuration. Notice the specific driver and interface name:
wpa_supplicant -B -Dnl80211 -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

Comments Off

Debian 7 – netinst

Comments Off

In search of a small simple GNU/Linux server setup, I started with a Debian 7 installation through a network based install – netinst. Using that image is simple, either by writing to a CD, or simply to a USB drive or memory card:
(Replace X with your flash drive, but be careful; everything will be overwritten, without any recovery option).

sudo dd if=debian-7.8.0-i386-netinst.iso.torrent of=/dev/sdX
The installation was straight forward, but it has to be hand-held since there are multiple prompts from various parts of the installation throughout. Unfortunately, the final step of writing out the GRUB configuration failed, since the install medium, the USB flash reader, was included in the GRUB device map. Removing it from /boot/grub/ fixed that, and a little rescue operation resolve the rest.

Once booted, there was a problem with the start-stop-daemon; for some reason, it was set to a fake mock implementation. That caused all services to not start. Swapping in with the real implementation took care of that:

mv /sbin/start-stop-daemon /sbin/start-stop-daemon.FAKE
ln -s /sbin/start-stop-daemon.REAL /sbin/start-stop-daemon

Finally, some essentials are always missing:

apt-get install emacs atop htop iftop iotop tree git tig sudo autossh iptables-persistent wpasupplicant cryptsetup smartmontools

Comments Off

Open a Firefox image in a VirtualBox guest OS

Comments Off

In my recent Ubuntu and Windows install for my father, a requirement was to open images shown in Firefox (which runs on the host Ubuntu OS) in Corel Paint Shop Pro which runs in the VirtualBox guest Windows 7 OS.

The command to execute an application from the host in the guest is vboxmanage guestcontrol [...] exec, documented here. It also needs the (guest OS) user credentials, the application to run and its arguments. Also note, that back-slashes have to be escaped, and since the path contains spaces it has to be in quotes.

The following assumes that the name of the VirtualBox machine is called “win7″, and application to run is PSP, and shows example values for username, password and filename.

Note that it also assumes that the Windows drive S:\ is a shared mount point between the host and guest OS, and that downloaded images is saved to that location.

vboxmanage guestcontrol win7 exec --image "C:\\Program Files (x86)\\Corel\\Corel PaintShop Pro X5\\Corel PaintShop Pro.exe" --username my_guest_user --password my_guest_password -- "s:\\image_file.png"

So far so good. However, to execute this for any image in Firefox proved a bit tricky. It does not seem to be possible to associate an Open action from the right-click menu with a given application in Firefox. The plugin “Open With Photoshop” came to the rescue. It gives an extra menu item when right-clicking on any image, and what most useful, it let’s you choose the executable to run.

I took the command above, and created my own script, e.g. “”, which looks like this:

b=`basename $f`
vboxmanage guestcontrol win7 exec --image "C:\\Program Files (x86)\\Corel\\Corel PaintShop Pro X5\\Corel PaintShop Pro.exe" --username $WINUSER --password $PASSWORD -- "s:\\$b" &> /tmp/open_with.log

I suppose a valuable addition would be to move the downloaded file to the correct location if necessary.

Comments Off

Default PDF viewer in Debian

Comments Off

By some strange logic, the primary and default application for viewing PDFs in Debian is Gimp. If you want to edit the PDF, that might make sense, but that is not the most common use case. There is a bug and discussion about this, but unfortunately, in somebody’s stubborn opinion, “it is not a bug”, and was closed many years ago.

Luckily it is easy to fix. The default setting can be found in the file /usr/share/applications/mimeinfo.cache which contains this line:

Notice how Gimp is listed first, while the PDF viewers ePDFViewer and Evince are last in the list. You can edit that file (as root). Or if you prefer you can override the user local setting in /home/$USER/.local/share/applications/mimeinfo.cache, and insert something like


The change should take effect immediately, across all applications and browsers, unless the default is overridden there. E.g. Firefox and Chrome have their own internal PDF viewers, however the default MIME applications will be available for selection when the file is downloaded.

Comments Off

Git branch in zsh prompt

Comments Off

When working in a git directory, I would like to see the current branch as part of the Zsh prompt. There are more advanced use cases out there, but I’ll stick with the branch name for now.

The following lines in ~/.zshrc takes care of the prompt. There are a few gotchas, though: The git command will fail if not in a git controlled directory, so we’ll have to hide that failure message. Then, for Zsh to execute the function, rather than printing its verbatim name, the prompt_subst option has to be set. Finally, it is important to use single quotes for the PROMPT line. If double quotes are used, the first output of the function is used, and never called again.

function get-git-branch {
  b="`git symbolic-ref --short HEAD 2> /dev/null`" && echo "($b)" || echo ""
setopt prompt_subst
PROMPT='%n@%2m %~ $(get-git-branch) %# '

Comments Off

Key mappings in Zsh

Comments Off

Z-Shell is a powerful alternative to Bash, but some of the details can take time to get use to, and some things just have to be changed. For example, the key binding for cursor and other special keys. Using CTRL + arrow keys to skip words might give funny characters like “;5D” and “;5C” instead. As pointed out by Luke Wilde, these keys have to be set up manually. In my case, I had to include the semi-colon in the bindkey command as well.

These should go in ~/.zshrc.

bindkey ';5D' emacs-backward-word
bindkey ';5C' emacs-forward-word
export WORDCHARS=''

Only funny thing about setting it up like that, is that if the actual character sequence “;5D” is pasted into the terminal, it will be taken as if the CTRL+LEFT key was pressed. I’m not aware of a work-around for that.

The Zsh wiki lists a few other possible key bindings, including for the Home and End keys:

bindkey "${terminfo[khome]}" beginning-of-line
bindkey "${terminfo[kend]}" end-of-line

Comments Off

Multiplexed SSH sessions for quicker connection

Comments Off

If you need to open multiple SSH connections to the same host, it can get tedious to re-authenticate for every one. And even with public key authentication and no password, the extra channel eats a bit of bandwidth. The solution is multiplexed SSH sessions: Authenticate once, and the following connections to the same host goes over the same session. It’s dead easy to set up:

In your ~/.ssh/config file add the following lines. (Make sure that file has user permissions only, i.e. 600).

Host *
   ControlMaster auto
   ControlPath ~/.ssh/master-%r@%h:%p

It takes effect immediately. SSH twice to the same host to verify.

Comments Off

chroot to ARM

Comments Off

chroot allows you to “run a command or interactive shell with special root directory”, as the man page says. However, it is assumed that the second level root directory is built for the same CPU architecture. This causes a problem if you want to chroot into an ARM based image, for the Raspberry Pi, let’s say. qemu-arm-static, some “voodoo” and several tricks come to the rescue. The process is documented well at Sentry’s Tech Blog, and the original seems to be by Darrin Hodges.

After downloading and unzipping the image, it has to be mounted. There are a few ways to go about this, but I found the easiest was to use plain old mount with an offset. The typical RPi image file is a full disk image, as opposed to a single partition or ISO though. We are after the second partition, which in our case starts at sector 122880. (See this discussion for how to find the correct starting sector using fdisk).

mkdir /mnt/rpi
mount -o loop,offset=$(( 512 * 122880 )) 2014-01-07-wheezy-raspbian.img /mnt/rpi

Next we’ll copy a statically built QEMU binary for ARM to the mounted image. You might need to install QEMU on the host system first. Furthermore, we need to mount or bind the special system directories from the host to the chroot.

apt-get install qemu-user-static
cp /usr/bin/qemu-arm-static /mnt/rpi/usr/bin/

mount -o bind /dev /mnt/rpi/dev
mount -o bind /proc /mnt/rpi/proc
mount -o bind /sys /mnt/rpi/sys

Next comes the magic. This registers the ARM executable format with the QEMU static binary. Thus, the path to qemu-arm-static has to match where it is located on the host and slave systems (as far as I understand).

echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register

Finally, it’s time for the moment of truth:

chroot /mnt/rpi

uname -a
Linux hrb 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 armv7l GNU/Linux

In some cases, the error “qemu: uncaught target signal 4 (Illegal instruction) – core dumped” occurs. User kinsa notes here that the lines of the file (i.e. on the slave, /mnt/rpi/etc/ has to be commented out (with a # in front).

Congratulations, you now have an ARM based chroot. What to do with it? Maybe install a few “missing” packages before copying over to one or more SD cards, set up the users, modify passwords, etc. Or take advantage of the CPU and memory of the host system or compile from source.

apt-get install htop tree ipython ipython3 gnuplot

As a final note, when done, you want to clean up the mount points.

umount /mnt/rpi/dev
umount /mnt/rpi/proc
umount /mnt/rpi/sys
umount /mnt/rpi

Comments Off

Fedora 20 released

Comments Off

Fedora 20 was released a few days ago. J.A. Watson at ZDNet has a brief overview of the different desktops available, and concludes that for the most they run just fine on any hardware, including “sub-notebooks”. Furthermore, even though the “spin” of each desktop have specialised in their own applications, there are always plenty more to chose from in the main Fedora repositories.

The Anaconda installer was written back in release 18, and FedUp (FEDora UPgrader) is now the main system upgrade tool. It is not quite clear whether it is preferred to perform that on a running system though, as opposed to booting from an installer image.

Thus, the following links still apply, even for existing installations:

Comments Off

Building XBMC on the RPi

Comments Off

Some notes on building XBMC from source on the Raspberry Pi: I started with the Raspbian 2013-09-25-wheezy image from here. After basic setup, I switched to CLI only, set the GPU memory to 16 MB, logged in over SSH, and started a screen session. A remote session is preferred, since there will be a lot of coping back and forth between the RPi and your desktop.

For the most, I followed these instructions, with a few modifications: First, the boot files to set GPU memory are not there in the Raspbian distribution I had installed. Instead, I used raspi-config to set the memory split. Secondly, the large one-liner apt-get install of all the dev packages (step 4 in the instructions) did not work very well. It gave dependency conflicts with the mesa packages. I found myself splitting up that line into many chunks, which then worked fine. Finally, a few packages were missing, and I had to run configure several times to figure that out. In the end, I also installed these:

apt-get install dh-autoreconf gawk gperf zip ccache

For a successful build, I had to modify the search path of a header file. There are a few ways to go about that, as discussed here. I used this solution:

sudo sed -i 's/#include "vchost_config.h"/#include "linux\/vchost_config.h"/' /usr/include/interface/vmcs_host/vcgencmd.h

That took me as far as a working XBMC setup, however videos are not playing. With MPlayer there is no problem, but XBMC just gives a black screen. I will have to investigate further.

There’s a similar set of instructions here.

Comments Off

Firefox plug-ins and fixes

Comments Off

Firefox wants to be like Chrome. I’d rather just keep my old Firefox. Here’s the list of fixes to restore or remove some of their blunders:

Disable the “fancy” stuff. These settings can be reached from the special about:config page. I disable these

  • browser.tabs.animate
  • browser.tabs.insertRelatedAfterCurrent
  • keyword.enabled
  • browser.fixup.alternate.enabled

Then some plug-ins:

Comments Off

perceptualdiff – compare images perceptually

Comments Off

I recently found myself needing to compare bitmap images, to see if they were about the same. The images were from Gnuplot generate graphs, and I wanted to check whether subtle changes in the data had not introduced unexpected changed to the plot. A simple binary diff told me that there were indeed some differences, however, comparing them manually was not possible.

Enter the handy tool perceptualdiff, which lets you compare TIF and PNG images based on a perceptual metric. It actually goes beyond simple bitwise pixel diff, and tries to compare based on a model of the human visual system. Consider the examples below, and it is clear that it is a useful tool. It makes it easy to see where the small differences were introduced. (As it turns out, it is only the result of the two plots being generated on different machines, with different versions of Gnuplot and possibly also different available fonts).

The tool is in the Fedora repository, so a simple yum is enough:
yum install perceptualdiff

To generate an output diff image, this command does the job:
perceptualdiff -output diff.ppm image1.png image2.png

Comments Off

Fonts for Gnuplot

Comments Off

After struggling with fonts in Gnuplot 4.6 (on Fedora 17) (getting the not so useful error “gdImageStringFT: Could not find/open font while printing string”), I found tonicas post on debugging the issue. Although helpful, it did not give the full solution to my problem. It turns out, many of the old fonts are not available in Fedora 17 at all.

I wanted a sans-serif font, and in the end I went for the DejaVuSans. After installing the font packages, I specifically exported that path for use with Gnuplot:

sudo yum install dejavu-sans-fonts dejavu-fonts-common
export GDFONTPATH=/usr/share/fonts/dejavu

Then I can use that font in Gnuplot by addressing it specifically:

set title 'Test' font 'DejaVuSans,21'

Comments Off

Bodhi Linux on Nexus 7


Bodhi Linux is a Debian based distribution using the Enlightenment Window Manager. They have taken the effort to make a Nexus 7 image (ARM HF), and have gone for the very simple approach seen by the Ubuntu folks: Simply flash the boot and userdata partitions, and you’re ready to go.

The images can be found here. (Notice, there are actually two different kinds; boot and root, with different versions of the later). After unpacking, it boils down to:
sudo fastboot erase boot
sudo fastboot erase userdata
sudo fastboot flash boot boot.img
sudo fastboot flash userdata rootfs.img
sudo fastboot reboot

With the Enlightenment WM, they have actually managed to come further towards a UI which suits a small touch screen (compared to the Ubuntu and KDE Plasma Active UIs). The top panel features large buttons, and overall the interaction feels snappy. Now, they have of course not managed to cover all the upstream applications, which is now the next frontier for all of these distributions.

As it is Debian based, is uses the the Debian repositories, and just like the Ubuntu ones, a lot of applications have already been cross-compiled to ARM HF (Hard Floating point). As a crude test, Eclipse-JDT installed and started up fine, While Libreoffice-Writer was missing a package. glxgears installs, but does not start; possibly a driver issue. USB OTG with a hub, keyboard and mouse works out of the box.

So far, this is the best alternative GNU/Linux based distribution for Nexus 7 I’ve tested. However, as mentioned before, these are still early days, and there will be a lot of work for both upstream application maintainers and distributions to create a great UI experience suited for a touch screen.