Rhevin

Rhevin


Thoughts, stories and ideas.

Rhevin F
Author

Share


Tags


Decrypt Chef secret manually

Chef


make sure to change keyfile and encrypted_file variable with your existing databags secret and your result file name, save as script.rb then run it

require 'chef/encrypted_data_bag_item'
require 'json'

keyfile = "encrypted_databag_secret"
encrypted_file = "encrypted_file.json"

secret = Chef::EncryptedDataBagItem.load_secret(keyfile)
encrypted_data = JSON.parse(File.read(encrypted_file))
plain_data = Chef::EncryptedDataBagItem.new(encrypted_data, secret).to_hash
puts JSON.generate(plain_data)
script.rb
Rhevin F
Author

Rhevin F

View Comments