module SSHKeygen::SSHKeygenProvider

provider fucntions for the SSHKeygen Chef resoruce provider class

Public Instance Methods

create_key() click to toggle source
# File lib/ssh_keygen/provider.rb, line 76
def create_key
  converge_by("Create SSH #{new_resource.type} #{new_resource.strength}-bit key (#{new_resource.comment})") do
    @key = ::SSHKeygen::Generator.new(
      new_resource.strength,
      new_resource.type,
      new_resource.passphrase,
      new_resource.comment
    )
  end
end
save_private_key() click to toggle source
# File lib/ssh_keygen/provider.rb, line 87
def save_private_key
  converge_by("Create SSH private key at #{new_resource.path}") do
    f = file new_resource.path do
      action :nothing
      owner new_resource.owner
      group new_resource.group
      mode 0600
      sensitive true
    end
    f.content(@key.private_key)
    f.run_action(:create)
  end
end
save_public_key() click to toggle source
# File lib/ssh_keygen/provider.rb, line 101
def save_public_key
  converge_by("Create SSH public key at #{new_resource.path}") do
    f = file "#{new_resource.path}.pub" do
      action :nothing
      owner new_resource.owner
      group new_resource.group
      mode 0600
    end
    f.content(@key.ssh_public_key)
    f.run_action(:create)
  end
end
update_directory_permissions() click to toggle source
# File lib/ssh_keygen/provider.rb, line 114
def update_directory_permissions
  return false unless new_resource.secure_directory
  converge_by("Update directory permissions at #{File.dirname(new_resource.path)}") do
    directory ::File.dirname(new_resource.path) do
      action :create
      owner new_resource.owner
      group new_resource.group
      mode 0700
    end
  end
end