Waiting for server to accept SSH connections

Sometimes one needs to wait for a just booted server to accept SSH connections. This can be solved with a one-line bash script:


Posted in Uncategorized | Comments Off on Waiting for server to accept SSH connections

npm install fails with “npm ERR! tar.unpack untar error”


npm failed randomly while installing packages. It didn’t matter which packages or if running on Debian itself or inside virtual machines using Ubuntu (vagrant). Upgrading npm to the latest version ( sudo npm install -g npm@latest ) and clearing npm’s cache ( npm cache clean ) didn’t help either.

After examining the downloaded temporary packages in /tmp  I realized that they were corrupt. The corrupt packages changed randomly on every download attempt. Changing the temporary directory from /tmp  to another location did not resolve the issue. Every user on the machine was affected by the problem.

Since the issue occured on every platform for every user, inside vagrant-VMs and even on different machines (Laptop, Desktop-PC, …) it was soon clear that the solution probably had nothing to do with npm.

After weeks of troubleshooting without any result I realized that the problem only ocurred when running the command at home. The command executed fine when my Laptop was inside other networks. This led me to the conclusion that the network configuration was the cause of all problems. Since all machines received their settings via DHCP my first try was to manually define the DNS settings.

Et voilà: Everything worked as expected.


Change the DNS servers you use. You’re probably using the default servers provided by your ISP. There are plenty of other public DNS servers out there. For a quick test you might even use the ones operated by Google:  and .

Posted in Debian, Node.js, Ubuntu, Vagrant | Comments Off on npm install fails with “npm ERR! tar.unpack untar error”

Simulate the environment of Cron Jobs

Often you will find yourself in the situation that one of your cron jobs works perfectly if you execute it manually but fails as soon as is gets executed by cron. The root cause might be the different environment. To simulate the environment of a cron job add the following entry to your crontab using crontab -e:

This will create the file cronenv in your root directory and dump all available environment variables into it. Once the file was created remove the entry from your crontab and take a look at its contents:

This pretty much sums up the environment. To enter this environment use the following command:

Now you can execute your cron job command, see what happens and fix your error. Once you’re done simply type exit to leave the environment.

See this Stack Overflow answer for more information.

Posted in Uncategorized | Comments Off on Simulate the environment of Cron Jobs

Ubuntu: Mount encrypted home directory

After changing harddrives I needed to transfer some files from the old harddrive which had an encrypted home directory. The command

did not work:

http://askubuntu.com/a/36783 pointed me in the right direction. First mount the old hard drive in the new Ubuntu installation. Then run

to add the corresponding passphrase (32 digits). Remember the second sig and mount your directory with

You will need to answer some questions. The suggested default works except for the following two questions:


In my case some warnings were shown saying that encryption may not have worked properly and if mounting should continue. Despite those warnings all files were accessible.

Posted in Ubuntu | Comments Off on Ubuntu: Mount encrypted home directory