4
votes

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?

1
ah, just figured out my problem, which was very simple. In the directory that I was attempting to upload the cookbooks from, I had a knife.rb file which did not specify the keys, etc, so knife was using that to configure itself and resulting in the errors. I got the subsequent errors because I was still in that directory. Duh... ;-) Bottom line: make sure your knife.rb over ride file in any projects specifies your server and key attributes if you're going to be interacting with a chef-server - wkhatch

1 Answers

5
votes

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.