chef knife fails with key error after attempting to upload a cookbook

wkhatch picture wkhatch · Jul 8, 2013 · Viewed 9.9k times · Source

I set up a chef server, and after copying the admin.pem, and validator.pem files from the server to my workstation, and then configuring knife on the workstation using knife configure..., I create a new user which I can verify from the web ui, and, I'm able to successfully run knife client list and other knife commands. Then I attempt to upload a cookbook, via

knife cookbook upload -o cookbooks/ apache2

and I get this error:

ERROR: Your private key could not be loaded from /etc/chef/client.pem
Check your configuration file and ensure that your private key is readable

and all subsequent knife commands will return this error. The only thing I can do to get it working again is re run "knife configure -i...."

What's happening, and what am I doing wrong? I'm not creating new nodes or clients first, just trying to upload the cookbooks. Is that my problem? Still, it seems that the cookbook upload failure shouldn't result in completely messing up the knife config, yes?

Answer

Rajesh Hegde picture Rajesh Hegde · Jul 12, 2013

Have you copied admin.pem and validation.pem to ~/.chef directory.

First make sure that you are executing the command in the same directory where your knife.rb is stored. This is the best way to run knife command. Otherwise you can run the command knife configure client . to create new client.pem and client.rb file.