-
Install ruby
apt-get install ruby1.9.1-full
-
Install chef
gem1.9.1 install chef
-
May be you have to adjust the
$PATH
variableexport PATH=$PATH:/var/lib/gems/1.9.1/bin/
-
Download the chef cookbook
git clone https://github.com/TelekomLabs/chef-ssh-hardening.git
-
Move hardening to
cookbooks
mkdir cookbooks mv chef-ssh-hardening cookbooks/ssh-hardening
-
Download some dependences for the os-hardening cookbook
cd cookbooks git clone https://github.com/edelight/chef-solo-search cd ..
-
Add a public key to the root user
data_bags/users/root.json
{ "id" : "root", "ssh_rootkeys" : "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TCCCCCCjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qPasgCgzUFtdOKLv6IedplqoPasdasd0aYet2PkEDo3MlTBckFXPITAMzF8dJSICCCCFo9D8HfdOV0IAdx4O7dETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIUc9c9WhQ== vagrant insecure public key" }
-
Create
solo.rb
This file is used to specify the configuration details for chef-solo. So create a
solo.rb
that include thecookbook_path
and thedata_bags
.cookbook_path "cookbooks" data_bag_path "data_bags
-
Create
solo.json
Chef-solo does not interact with the Chef Server. Consequently, node-specific attributes must be located in a JSON file on the target system. Create the following
solo.json
.{ "ssh" : { "listen_to" : "10.0.2.15" }, "run_list":[ "recipe[chef-solo-search]", "recipe[ssh-hardening::server]" ] }
-
Run chef-solo
chef-solo -c solo.rb -j solo.json