Improve key generation command to avoid linefeed issues

See comments in CHEF-4506.