How Do You Troubleshoot Chef’s Knife Command When You Get An Error About “Failed to read the private key”?

Problem scenario:  You are using knife commands and getting errors.  For example, you try to run this: knife client list
As a result, you get this error:

"WARN: Failed to read the private key /root/.chef/continual.pem: #<Errno::ENOENT: No such file or directory @ rb_sysopen - /root/.chef/continual.pem>
ERROR: Your private key could not be loaded from /root/.chef/continual.pem
Check your configuration file and ensure that your private key is readable"

What should you do?

Obtain a copy of the .pem file from the Chef server. Then place a copy on the Chef client.  Specifically place a copy in /root/.chef/ with the name continual.pem (assuming you were root when you ran the "knife client list" command).

If you were not root, make sure the user running the knife command has access to the copy of the .pem file.  The client.rb file should be configured to find the copy of the .pem file.  Custom locations are possible with the client.rb file.  As long as the .pem file is where the client.rb file is configured, you should not get errors unless there is a permissions problem.

Leave a comment

Your email address will not be published. Required fields are marked *