Knife bootstrap on linux failing with error in /etc/chef/validation.pem

Hello All,
I am a chef begineer and trying to bootstrap a linux workstation (node) but its failing due to incorrect format (The key file should begin with ‘-----BEGIN RSA PRIVATE KEY-----’ and end with ‘-----END RSA PRIVATE KEY-----’)

I checked this file on chef server and this file is auto generated. I tried renaming it but on next attempt its creating same file with same error(see below). Please guide me in fixing this error.

ls -la /etc/chef/validation.pem*
-rw------- 1 root root 1676 Jun 10 16:03 /etc/chef/validation.pem
-rw------- 1 root root 1676 Jun 10 15:58 /etc/chef/validation.pem_old

install details-
chef server running on chef-server-core-12.6.0-1.el6.x86_64 --> centos 6
chef workstation running on chefdk-0.14.25-1.el7.x86_64 --> centos 7

below is the exact command I ran on workstation and knife client list is working fine.

[abc123@gacdtl021t186b4 chef-repo]$ knife bootstrap gacdtl02abc123 -x abc123 -A --sudo -N chefwkstn
Doing old-style registration with the validation key at /home/abc123/chef-repo/.chef/ccr-ldap-validator.pem…
Delete your validation key in order to use your user credentials instead

Connecting to gacdtl02abc123
abc123@gacdtl02abc123’s password:
gacdtl02abc123 knife sudo password:
Enter your password:
gacdtl02abc123
gacdtl02abc123 -----> Installing Chef Omnibus (-v 12)
gacdtl02abc123 downloading https://omnitruck-direct.chef.io/chef/install.sh
gacdtl02abc123 to file /tmp/install.sh.6429/install.sh
gacdtl02abc123 trying wget…
gacdtl02abc123 el 6 x86_64
gacdtl02abc123 Getting information for chef stable 12 for el…
gacdtl02abc123 downloading https://omnitruck-direct.chef.io/stable/chef/metadata?v=12&p=el&pv=6&m=x86_64
gacdtl02abc123 to file /tmp/install.sh.6434/metadata.txt
gacdtl02abc123 trying wget…
gacdtl02abc123 sha1 44e71beed0cc0db2481c3e3d2108ad218c32dade
gacdtl02abc123 sha256 e51559dc7747c03b446f9d1a3cdbb122f274352ba0ed7dd8fdac41e10514b9e2
gacdtl02abc123 to file /tmp/install.sh.6434/chef-12.11.18-1.el6.x86_64.rpm
gacdtl02abc123 trying wget…
gacdtl02abc123 Comparing checksum with sha256sum…
gacdtl02abc123 Installing chef 12
gacdtl02abc123 installing with rpm…
gacdtl02abc123 Preparing… ########################################### [100%]
gacdtl02abc123 1:chef ########################################### [100%]
gacdtl02abc123 Thank you for installing Chef!
gacdtl02abc123 Starting the first Chef Client run…
gacdtl02abc123 Starting Chef Client, version 12.11.18
gacdtl02abc123 Creating a new client identity for chefwkstn using the validator key.
gacdtl02abc123
gacdtl02abc123 ================================================================================
gacdtl02abc123 Chef encountered an error attempting to create the client "chefwkstn"
gacdtl02abc123 ================================================================================
gacdtl02abc123
gacdtl02abc123 Platform:
gacdtl02abc123 ---------
gacdtl02abc123 x86_64-linux
gacdtl02abc123
gacdtl02abc123
gacdtl02abc123 Running handlers:
gacdtl02abc123 [2016-06-10T15:15:49-04:00] ERROR: Running exception handlers
gacdtl02abc123 Running handlers complete
gacdtl02abc123 [2016-06-10T15:15:49-04:00] ERROR: Exception handlers complete
gacdtl02abc123 [2016-06-10T15:15:49-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
gacdtl02abc123 Chef Client failed. 0 resources updated in 04 seconds
gacdtl02abc123 [2016-06-10T15:15:49-04:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
gacdtl02abc123 [2016-06-10T15:15:49-04:00] ERROR: The file /etc/chef/validation.pem or :raw_key option does not contain a correctly formatted private key.
gacdtl02abc123 The key file should begin with ‘-----BEGIN RSA PRIVATE KEY-----’ and end with '-----END RSA PRIVATE KEY-----'
gacdtl02abc123 [2016-06-10T15:15:49-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
[abc123@gacdtl021t186b4 chef-repo]$

Thanks and regards
Abhijit

Do mv /etc/chef /etc/chef.old and try again.

Do **mv /etc/chef /etc/chef.old** in gacdtl02abc123 and try again.

Thanks Arunv707 for reply.
I tried that today but got same results :frowning:

[2016-06-15T09:18:15-04:00] ERROR: The file /etc/chef/validation.pem or :raw_key option does not contain a correctly formatted private key.
gacdtl02abc123 The key file should begin with ‘-----BEGIN RSA PRIVATE KEY-----’ and end with '-----END RSA PRIVATE KEY-----'
gacdtl02abc123 [2016-06-15T09:18:15-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

listing on chef server is below-

/etc/chef:
total 16
-rw-r–r-- 1 root root 200 Jun 15 09:18 client.rb
-rw-r–r-- 1 root root 16 Jun 15 09:18 first-boot.json
drwxr-xr-x 2 root root 4096 Jun 15 09:18 trusted_certs
-rw------- 1 root root 1676 Jun 15 09:18 validation.pem

/etc/chef-manage:
total 4
-rw------- 1 root root 116 Jun 7 11:57 secrets.rb

/etc/chef_old:
total 20
-rw-r–r-- 1 root root 200 Jun 10 16:03 client.rb
-rw-r–r-- 1 root root 16 Jun 10 16:03 first-boot.json
drwxr-xr-x 2 root root 4096 Jun 10 15:15 trusted_certs
-rw------- 1 root root 1676 Jun 10 16:03 validation.pem
-rw------- 1 root root 1676 Jun 10 15:58 validation.pem_old

Did I missed any step here?

Regards
Abhijit

Could you please post the knife.rb?

if you open the validation.pem file on the server using vim do you see any extra characters before the -----BEGIN RSA PRIVATE KEY----- or after the -----END RSA PRIVATE KEY-----

I ran into a similar issue when the validation.pem that I was uploading was invalid due to some silliness with download in windows.