[Snippet] Restrict user to a particular folder

By default in Linux, an SSH can freely navigate around your file system. I recently needed to restrict an SSH user to their home directory. You need rbash.

CentOS doesn’t ship with rbash enabled as default. It was easy enough to solve.

[codesyntax lang=”bash”]
ln -s /bin/bash /bin/rbash

Then change /etc/passwd so that the user’s shell is /bin/rbash.

[Snippet] One line installation of wkhtmltopdf

A super quick, one line install of wkhtmltopdf

[codesyntax lang=”bash”]
wget https://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 && tar xvjf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 && mv wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf

Quite often you’ll need pdftk also

[codesyntax lang=”bash”]
wget http://pkgs.repoforge.org/pdftk/pdftk-1.44-2.el6.rf.x86_64.rpm && rpm -Uvh pdftk-1.44-2.el6.rf.x86_64.rpm && pdftk

Installing Linux HyperV Services

Here’s how I installed Linux HyperV Services on CentOS which allows vital integration between Linux hosts and Hyper-V Service Center Virtual Machine Manager such as Time Keeping, Drive Support, Fastpath Boot, Heartbeat, SMP, Live Migration and loads of other great things.

[codesyntax lang=”bash”]
wget http://download.microsoft.com/download/0/8/E/08EE288C-B81E-425A-85D1-67EA7155AB7E/LinuxICv35.iso
mount -o loop LinuxICv34.iso /mnt/
cd /mnt/RHEL63
sh install.sh


** Updated August 2014

CakePHP and Redis

I recently had to upscale a client’s CakePHP application across multiple front-end web servers on AWS. CakePHP’s file system cache and session storage doesn’t cut it any more. I needed a way of sharing sessions and cached objects. Step in Redis. A centralised, in-memory database, much like memcache – but nicer!

Continue reading “CakePHP and Redis”

How I installed Batik for HighCharts

Batik for HighCharts allows you to create static PNGs from dynamic data. HightCharts offers a hosted export server, sometimes I don’t want to use a 3rd party service.
Here’s how I installed the Apache Batik SVG Toolkit to create PNGs from HightCharts on CentOS

You’ll need a HighCharts download also.

yum install batik
yum install batik-rasterizer
chmod 777  highcharts/exporting-server/php/php-batik/temp
wget http://mirrors.enquira.co.uk/apache/xmlgraphics/batik/batik-1.7-jre13.zip
unzip batik-1.7-jre13.zip     
cd batik-1.7             
cp batik-rasterizer.jar lib/ ../highcharts/exporting-server/php/php-batik/ -r       
yum install bitmap*   
yum install dejavu*     
ln -s /usr/share/fonts/dejavu /usr/share/fonts/dejavu-lgc


SSH Error – ssh-error-trying-to-get-more-bytes-4-than-in-buffer-0

I’ve bumped into this message a few times on different servers. The message offers no insight into why you can’t connect to a remote server over SSH.
It usually means the the ~/.ssh/authorized_keys  file is corrupt, for example there is an incorrect or single corrupt line in this file. I’d recommend stepping through line by line and finding the offending line.


Change default cron editor on CentOS

Install nano

Installing nano is done using the yum system.

[codesyntax lang=”bash”]
yum -y install nano

System Default Editor

During login, a number of scripts are run to setup the environment. In CentOS, a file for each subject is used. These are stored in a system profile directory, /etc/profile.d/. There are two environment variables that control which editor to use.

[codesyntax lang=”bash”]
cat <<EOF >>/etc/profile.d/nano.sh
export VISUAL=”nano”
export EDITOR=”nano”