How to install Chef Server, Workstation and Chef Client on Ubuntu 18.04

Chef is a Ruby based configuration management tool used to define infrastructure as code. This enables users to automate the management of many nodes and maintain consistency across those nodes. Recipes declare the desired state for managed nodes and are created on a user’s workstation using the Chef Workstation package. Your recipes are distributed across nodes via a Chef server. A Chef client, installed on each node, is in charge of applying the recipe to its corresponding node. This guide will show you how to install and configure a Chef Server and Chef Workstation. We will also bootstrap a node to manage with Chef.

In this tutorial you will learn:

  • Install and Configure the Chef Server
  • Create Chef User and Organization
  • Install and Configure the Chef Workstation
  • Configure Knife and Bootstrapping a Client Node

Chef Architecture

Chef Architecture.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Linux 18.04
Software Chef Server Core, Chef Workstation, Chef Client, Chef Development Kit
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install and Configure the Chef Server

The Chef server is the hub of interaction between all workstations and nodes under Chef management. Changes made to configuration code on workstations are pushed to the Chef server, and then pulled by a node’s chef-client to apply the configurations.

Download the latest Chef server via running the below command:

# wget

Now install the server package by the following command:

# dpkg -i chef-server-core_*.deb

The Chef server includes a command line utility called chef-server-ctl. Run chef-server-ctl to start the Chef server services.

# chef-server-ctl reconfigure

Upon successful configuration of the chef server you will see the below message and check the chef server running status as well.

Chef Client finished, 493/1100 resources updated in 12 minutes 02 seconds
Chef Server Reconfigured!
root@ubuntubox1:~# chef-server-ctl status
run: bookshelf: (pid 1435) 6644s; run: log: (pid 1440) 6644s
run: nginx: (pid 1235) 6653s; run: log: (pid 1744) 6631s
run: oc_bifrost: (pid 1196) 6657s; run: log: (pid 1203) 6657s
run: oc_id: (pid 1220) 6655s; run: log: (pid 1227) 6655s
run: opscode-erchef: (pid 4376) 6432s; run: log: (pid 1508) 6644s
run: opscode-expander: (pid 1335) 6648s; run: log: (pid 1431) 6646s
run: opscode-solr4: (pid 1244) 6650s; run: log: (pid 1285) 6649s
run: postgresql: (pid 1176) 6659s; run: log: (pid 1180) 6659s
run: rabbitmq: (pid 4188) 6443s; run: log: (pid 1748) 6631s
run: redis_lb: (pid 27397) 6931s; run: log: (pid 1735) 6632s

Create Chef User and Organization

In order to link workstations and nodes to the Chef server, create an administrator and organization with associated RSA private keys.
From the home directory, create a .chef directory to store the keys.

# mkdir .chef

Use chef-server-ctl to create a user. In this example, change the following to match your needs: USER_NAME, FIRST_NAME, LAST_NAME, EMAIL, and PASSWORD. Adjust USER_NAME.pem, and leave the .pem extension.

chef-server-ctl user-create USER_NAME FIRST_NAME LAST_NAME EMAIL 'PASSWORD' --filename ~/.chef/USER_NAME.pem
root@ubuntubox1:~# chef-server-ctl user-create chefadmin Chef Administrator '*******' --filename ~/.chef/chefadmin.pem

To view the list of all users on your Chef server issue the following command:

root@ubuntubox1:~# chef-server-ctl user-list

Create an organization and add the user created in the previous step. Replace ORG_NAME with a short identifier for the organization, ORG_FULL_NAME with the organizations’ complete name, USER_NAME with the username created in the step above and ORG_NAME.pem with organization’s short identifier followed by .pem.

chef-server-ctl org-create ORG_NAME "ORG_FULL_NAME" --association_user USER_NAME --filename ~/.chef/ORG_NAME.pem
root@ubuntubox1:~# chef-server-ctl org-create chef-on-ubuntu "Chef Infrastructure on Ubuntu 18.04" --association_user chefadmin --filename ~/.chef/chef-on-ubuntu.pem

To view the list of all organizations on your Chef server, use the following command:

root@ubuntubox1:~# chef-server-ctl org-list

With the Chef server installed and the RSA keys generated, we will begin configuring the Chef workstation. The workstation is where all major configurations will be created for your nodes.

Install and Configure the Chef Workstation

The Chef workstation is where you create and configure any recipes, cookbooks, attributes, and other changes necessary to manage your nodes. Although this can be a local machine running any OS, there is some benefit to keeping a remote server as your workstation so you can access it from anywhere.

In this section, you will download and install the Chef Workstation package, which provides all tools also included with the ChefDK, Chef’s development kit.

Download the latest Chef Workstation:

root@ubuntubox2:~# wget
--2019-06-03 13:35:51--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 129713682 (124M) [application/x-debian-package]
Saving to: ‘chef-workstation_0.2.43-1_amd64.deb’

chef-workstation_0.2.43-1_amd64.deb       100%[=====================================================================================>] 123.70M  1.51MB/s    in 80s

2019-06-03 13:37:17 (1.55 MB/s) - ‘chef-workstation_0.2.43-1_amd64.deb’ saved [129713682/129713682]

Install Chef Workstation:

root@ubuntubox2:~# dpkg -i chef-workstation_*.deb
Selecting previously unselected package chef-workstation.
(Reading database ... 117468 files and directories currently installed.)
Preparing to unpack chef-workstation_0.2.43-1_amd64.deb ...
Unpacking chef-workstation (0.2.43-1) ...
Setting up chef-workstation (0.2.43-1) ...

To run the experimental Chef Workstation App, use your
platform's package manager to install these dependencies: => not found
You can then launch the App by running 'chef-workstation-app'.
The App will then be available in the system tray.

Thank you for installing Chef Workstation!
You can find some tips on getting started at

Now we need to create the Chef repository. The chef-repo directory will store your Chef cookbooks and other related files.

# chef generate repo chef-repo

Create a .chef subdirectory. The .chef subdirectory will store the Knife configuration file and the .pem files that are used for RSA key pair authentication with the Chef server. Move into the chef-repo directory:

root@ubuntubox2:~# mkdir ~/chef-repo/.chef
root@ubuntubox2:~# cd chef-repo

Authentication between the Chef server and workstation and/or nodes is completed with public key encryption. This ensures that the Chef server only communicates with trusted machines. In this section, the RSA private keys, generated when setting up the Chef server, will be copied to the workstation to allow communicate between the Chef server and workstation.

We will generate a RSA key-pair on the workstation server. This key-pair will be used to gain access to the Chef server and then transfer their .pem files:

root@ubuntubox2:~# ssh-keygen -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
The key's randomart image is:
+---[RSA 4096]----+
|.. .  o.         |
|.E+ oo. .        |
| * o.o...        |
|+ o...   o +     |
|.  .. ooS = .    |
|    +o=oo+ .     |
|     Oo+oo.      |
|    ooO.+.       |
|   o=B=*.        |

Upload the workstation node’s public key to the Chef server node.

root@ubuntubox2:~# ssh-copy-id
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys's password:

Number of key(s) added: 1

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


Copy the .pem files from your Chef server to your workstation using the scp command.

root@ubuntubox2:~# scp*.pem ~/chef-repo/.chef/
chefadmin.pem                                                                                                                         100% 1674    27.9KB/s   00:00
chef-on-ubuntu.pem                                                                                                                    100% 1674   496.8KB/s   00:00

Confirm that the files have been copied successfully by listing the contents of the .chef directory. The .pem files should be listed.

root@ubuntubox2:~# ls ~/chef-repo/.chef
chefadmin.pem  chef-on-ubuntu.pem

Generate a new Chef cookbook:

root@ubuntubox2:~# chef generate cookbook chef-first-cookbook
Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See for more information.
Generating cookbook chef-first-cookbook
- Ensuring correct cookbook file content
- Ensuring delivery configuration
- Ensuring correct delivery build cookbook content

Your cookbook is ready. Type `cd chef-first-cookbook` to enter it.

There are several commands you can run to get started locally developing and testing your cookbook.
Type `delivery local --help` to see a full list.

Why not start by writing a test? Tests for the default recipe are stored at:


If you'd prefer to dive right in, the default recipe can be found at:


Generate the chef-repo and move into the newly-created directory:

# chef generate app chef-repo
# cd chef-repo

Configure Knife and Bootstrapping a Client Node

Create a knife configuration file by navigating to ~/chef-repo/.chef directory and creating a file named config.rb using your preferred text editor.

Copy the following configuration into the config.rb file:

current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                'node_name'
client_key               "USER.pem"
validation_client_name   'ORG_NAME-validator'
validation_key           "ORGANIZATION-validator.pem"
chef_server_url          ''
cache_type               'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path            ["#{current_dir}/../cookbooks"]

The value for node_name should be the username that was created on the Chef server.
Change USER.pem under client_key to reflect the .pem file for chef user.
The validation_client_name should be the organization’s ORG_NAME followed by -validator.
ORGANIZATION-validator.pem in the validation_key path should be set to the ORG_NAME followed by -validator.pem.
Finally the chef_server_url should be the Chef server’s domain with /organizations/ORG_NAME appended. Be sure to replace ORG_NAME with the organization’s name.

Move to the chef-repo directory and copy the needed SSL certificates from the server:

root@ubuntubox2:~/chef-repo/.chef# cd ..
root@ubuntubox2:~/chef-repo# knife ssl fetch
WARNING: Certificates from will be fetched and placed in your trusted_cert
directory (/root/chef-repo/.chef/trusted_certs).

Knife has no means to verify these are the correct certificates. You should
verify the authenticity of these certificates after downloading.

Adding certificate for ubuntubox1_com in /root/chef-repo/.chef/trusted_certs/ubuntubox1_com.crt

Confirm that config.rb is set up correctly by running the client list. This command should output the validator name.

root@ubuntubox2:~/chef-repo# knife client list

Bootstrapping a node installs the Chef client on the node and validates the node. This allows the node to read from the Chef server and pull down and apply any needed configuration updates detected by the chef-client.
From the workstation, navigate to ~/chef-repo/.chef directory:

# cd ~/chef-repo/.chef

Bootstrap the client node either using the client node’s root user, or a user with elevated privileges:

root@ubuntubox2:~/chef-repo/.chef# knife bootstrap -x root -P ******* --node-name chef-client-node
Creating new client for chef-client-node
Creating new node for chef-client-node
Connecting to -----> Installing Chef Omnibus (-v 14) downloading   to file /tmp/ trying wget... ubuntu 18.04 x86_64 Getting information for chef stable 14 for ubuntu... downloading   to file /tmp/ trying wget... sha1     ed9b1fcdaf947d9a3d60e6d196308183a082bcff sha256   9ddcd5ceef19c95ecc1f34bef080c23d9cb42ae8ebc69fd41dcf1c768a6a708f url version  14.13.11 downloaded metadata file looks valid... downloading   to file /tmp/ trying wget... Comparing checksum with sha256sum... Installing chef 14 installing with dpkg... Selecting previously unselected package chef.
(Reading database ... 117468 files and directories currently installed.) Preparing to unpack .../chef_14.13.11-1_amd64.deb ... Unpacking chef (14.13.11-1) ... Setting up chef (14.13.11-1) ... Thank you for installing Chef Infra Client! For help getting started visit Starting the first Chef Client run... Starting Chef Client, version 14.13.11 resolving cookbooks for run list: [] Synchronizing Cookbooks: Installing Cookbook Gems: Compiling Cookbooks... [2019-06-03T14:01:44+04:00] WARN: Node chef-client-node has an empty run list. Converging 0 resources Running handlers: Running handlers complete Chef Client finished, 0/0 resources updated in 05 seconds
Confirm that the node has been bootstrapped by listing the client nodes:

Confirm that the node has been bootstrapped successfully by listing the nodes:

root@ubuntubox2:~/chef-repo/.chef# knife node list
root@ubuntubox2:~/chef-repo/.chef# knife node show chef-client-node
Node Name:   chef-client-node
Environment: _default
Run List:
Platform:    ubuntu 18.04


In this detailed article we learnt about the Chef Configuration Management tool with its basic understanding and overview of its components with installation and configuration settings. You can learn more about Chef by visiting the Chef website i.e.