Enable file sharing on Windows servers in Amazon Web Services (AWS)

When you create an EC2 instance in Amazon Web Services (AWS) the security group (firewall) blocks all ports that are not explicitly opened. To make file sharing possible on Windows servers, open the following ports in the security group of the server:

  • TCP 139
  • TCP 445

How to copy files to the clipboard

When you work in the graphical user interface (GUI) of your operating system, and want to copy the contents of a file to the clipboard, you can use the following commands:

On OS X run: cat FILE_NAME | pbcopy
On Linux run: cat FILE_NAME | xclip
On Windows (via Cygwin/Git Bash) run: cat FILE_NAME | clip

How can I tell if a Chef cookbook is frozen

If a Chef cookbook is “frozen”, the cookbook is protected against accidental overwrite.

When someone tries to overwrite it the
Version ... of cookbook COOKBOOK_NAME is frozen. Use --force to override"
message appears.

To check if a Chef cookbook is frozen on the Chef server execute the following command
knife cookbook show COOKBOOK_NAME latest | grep frozen

To upload a Chef cookbook and freeze it to prevent accidental overwrite
knife cookbook upload COOKBOOK_NAME --freeze

To overwrite a frozen cookbook upload it with
knife cookbook upload COOKBOOK_NAME --force

To freeze the referenced cookbooks when you upload them with BerkShelf upload them with
berks upload
(do not use the –no-freeze option)

REMOTE HOST IDENTIFICATION HAS CHANGED warning when you try to connect to a server with ssh

If you work in the AWS environment and  launch and terminate servers frequently the same IP is reused many times. When you try to connect to a new server with SSH and the IP address is already in the known_hosts file you will get the following error message.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:...
Please contact your system administrator.
Add correct host key in /c/Users/.../.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /c/Users/.../.ssh/known_hosts:13
ECDSA host key for ... has changed and you have requested strict checking.
Host key verification failed.

The solution is to delete the line from the “c:/Users/YOUR_USER_NAME/.ssh/known_hosts” file that has the same IP address as the new server.

SSL certificate is missing after installing ChefDK

When you install a new version of ChefDK and try to run Test Kitchen converge you may get the following error message
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

To solve the problem add the following to the Windows environment variables and open a new Command or Bash window for the change to take effect:
SSL_CERT_FILE=C:\opscode\chefdk\embedded\ssl\certs\cacert.pem

Winrm is missing after installing ChefDK

When you install the new version of ChefDK you may get the following error message when you try to run Test Kitchen
!!!!!! The `winrm` gem is missing and must be installed or cannot be properly activated. Run `gem install winrm --version '["~> 1.6"]'` or add the following to your Gemfile if you are using Bundler: `gem 'winrm ', '["~> 1.6"]'`.

To install Winrm for the correct Ruby version execute
gem install winrm
gem install winrm-fs

Berkshelf is missing after installing ChefDK

When you install a new version of ChefDK and try to run Test Kitchen the following error message may appear
!!!!!! The `berkshelf' gem is missing and must be installed or cannot be properly activated. Run `gem install berkshelf` or add the following to your Gemfile if you are using Bundler: `gem 'berkshelf'`.

To reinstall Brekshelf in the correct version of Ruby execute
gem install berkshelf

EC2 driver is missing after installing ChefDK

After installing a new version of ChefDK you may get the following error message when you try to run Test Kitchen:

Message: Could not load the 'ec2' driver from the load path. Please ensure that your driver is installed as a gem or included in your Gemfile if using Bundler.

To install the EC2 driver in the correct Ruby version execute

gem install kitchen-ec2