Page 2 of 10

Hide Apache server signature

In default Apache write server signatures to HTTP-responses. In production server this is not recommended action, because it gives more attacking area to criminals. Web servers would like to advice themselves and that is the reason why they add their signatures in default to HTTP-responses.

In this post I will show you how to hide unnecessary Apache server signature.

Tested on Ubuntu 14.04 and Ubuntu 12.04.

At beginning

you can watch how your server HTTP-response looks like now. Do HTTP-request e.g. with curl:

$ curl -I

There is your HTTP-header and now you see exactly what all informations Apache gives to client. We still want to limit information of our server from outside.

Hide Apache signatures

At first open Apache configuration file apache2.conf

$ sudoedit /etc/apache2/apache2.conf

Add two lines on below to apache2.conf

ServerTokens Prod
ServerSignature Off

Save file and reload Apache daemon

$ sudo service apache2 reload

Hide also information of PHP

If you are using PHP HTTP-header also contain some information of PHP. Here is the way how to hide it.

Open php.ini

$ sudoedit /etc/php5/apache2/php.ini

In default expose_php is set to On, but now you take it Off

; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header).  It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
expose_php = Off

After changes you have to reload Apache

$ sudo service apache2 reload

Now you’re a little further safe.

WordPress quickly upgrade from command line

WordPress has their own guide to upgrade wordpress, but in this post I will show you how I upgrade my all wordpress sites.

I using Ubuntu 14.04 server and I update wordpress from command line.


Before upgrade we backup our database and wordpress directory.

$ mkdir -p ~/backup
$ mysqldump -u user -p <database name> | gzip -9 > ~/backup/$(date +"%Y%m%d")_wordpress.sql.gz
$ tar -zcvf ~/backup/$(date +"%Y%m%d")_wordpress-dir.tar.gz /home/niko/public_html/

Download wordpress

$ cd /tmp/
$ wget
$ unzip

Overwrite all new files

Remember change current directory to where wordpress located in your server.

$ cd ~/public_html/
$ cp -avr /tmp/wordpress/* .
$ rm -rf /tmp/wordpress /tmp/

Open in a browser and run that script. It makes all needed database conversions. If something fails, you still have your backups in ~/backup/ directory.


How to install Ruby on Windows

In this post, I’ll tell how you can install Ruby script language on Windows.
This post is made for 64-bits architecture’s, but 32-bits is installing mostly same way.

Download and install

1. Download Ruby 2.0.0 x64 (
2. Double click Ruby setup icon, and follow setup wizard to forward. HOX! Remember tap on “Add Ruby executables to your PATH”.
3. When setup is complete, run next command by command line:

> ruby -v

If you got response like: ruby 2.0.0p481, congratulations your Ruby works correctly! If not.. damn, then something went wrong..

Ruby DevKit

Ruby could use some native C/C++ extensions, so we need to install Ruby DevKit to get Ruby working as we would like it work.

Download Ruby development kit (, and extract it into Ruby path root (C:\Ruby200-x64\DevKit\).

Run next commands on command line:

> cd C:\Ruby200-x64\DevKit\
> ruby dk.rb init
> echo -- C:\Ruby200-x64 >> config.yml
> ruby dk.rb install

Now you should are able to run native C/C++ extensions by Ruby.

Create Puppet module test case less than 5 minutes

In this post, I’ll tell you how to create Puppet module test cases. If you are newbie with Puppet, I recommend you begin by my another post Hello Puppet!.

My using operating system is Xubuntu 14.04 LTS.

Hello Git!

As every project begin in Hello world, by the same way our project begin in Hello Git!

Create directory structure:

$ mkdir -p puppet/modules/git/manifests
$ cd puppet

Create init.pp in manifests:

$ nano modules/git/manifests/init.pp

And write bottom lines in file:

class git {

  package { 'git':
    ensure => 'installed',


Run our git module:

$ puppet apply --modulepath modules/ -e 'class {"git":}'

And now git should be installed to our system.

Create test case

Is time to go on and let make our first test case. In web, I have seen many different variations to make this part of post. But I like to make things easiest way as possible, so I’ll show you how to make this part as simplest I know so far.

Goto git module root:

$ cd modules/git

Write necessary gems in Gemfile.

$ nano Gemfile

source ''
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'rspec', '>=3.1.0'
gem 'rspec-puppet'

And bundle install gems:

$ bundle install

Run command rspec-puppet-init, and we got full nicely generated spec directory structure:

$ rspec-puppet-init

 + spec/
 + spec/classes/
 + spec/defines/
 + spec/functions/
 + spec/hosts/
 + spec/fixtures/
 + spec/fixtures/manifests/
 + spec/fixtures/modules/
 + spec/fixtures/modules/git/
 + spec/fixtures/manifests/site.pp
 + spec/fixtures/modules/git/manifests
 + spec/spec_helper.rb
 + Rakefile

Rspec-puppet for some reason miss require puppetlabs_spec_helper. We add it into bottom of file:

$ echo "require 'puppetlabs_spec_helper/rake_tasks'" >> Rakefile

Write some test case. That is the way, how we verify and be sure that our git class contain package git.

$ nano spec/classes/git_spec.rb

require 'spec_helper'

describe 'git', :type => 'class' do
  context 'install git' do
    it { should contain_package('git') }

And now we’re able to run our test case. Because we are using Gemfile, is very important to run rake spec with bundle! If you’re not using bundle, you’re not even use Gemfile, so you’re not using your specified gems versions! It isn’t good practice, so use bundle:

$ bundle exec rake spec

/home/niko/.rvm/rubies/ruby-2.1.2/bin/ruby -I/home/niko/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.7/lib:/home/niko/.rvm/gems/ruby-2.1.2/gems/rspec-support-3.1.2/lib/home/niko/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.7/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color

Finished in 1.06 seconds (files took 0.78309 seconds to load)
1 example, 0 failures


Login with ssh key and disable user password login

In this post, I’ll tell you, how to create new user in Ubuntu 14.04 and how you disable user password login.

New user

Create new user, in my e.g. it’s example-user. Set strong password, and fill fields.

$ sudo adduser example-user

SSH key login

Now you’re created new user. In second step, we have to generate new ssh key (if you don’t already had it).

$ ssh-keygen

And use default value for:

Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa):

Next we need to copy our ssh key into example-user’s authorizies keys file (~/.ssh/authorized_keys).

$ ssh-copy-id [email protected]

If you got next lines, you’re permit login to example-user by ssh key.

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh [email protected]'"
and check to make sure that only the key(s) you wanted were added.

Disable user password login

It mean that, you’re not longer need password to login example-user. So if we don’t any more need password to login our new user, we could disable password login to that user.

$ sudo usermod -L example-user

© 2017 Niko Kiuru

Theme by Anders NorenUp ↑