class Vagrant::Util::Keypair
Constants
- AUTH_MAGIC
Magic string header
- PREFER_KEY_TYPES
Ordered mapping of openssh key type name to lookup name. The order defined here is based on preference. Note that ecdsa ordering is based on performance
- PRIVATE_KEY_END
Footer of private key file content
- PRIVATE_KEY_START
Header of private key file content
- VALID_TYPES
Supported key types.
Public Class Methods
available_types()
click to toggle source
@return [Array<Symbol>] list of supported key types
# File lib/vagrant/util/keypair.rb, line 29 def self.available_types PREFER_KEY_TYPES.values end
create(password=nil, type: :rsa)
click to toggle source
Create a new keypair
@param [String] password Password for the key or nil for no password (only supported for rsa type) @param [Symbol] type Key type to generate @return [Array<String, String, String>] Public key, openssh private key, openssh public key with comment
# File lib/vagrant/util/keypair.rb, line 38 def self.create(password=nil, type: :rsa) if !VALID_TYPES.key?(type) raise ArgumentError, "Invalid key type requested (supported types: #{available_types.map(&:inspect).join(", ")})" end VALID_TYPES[type].create(password) end
valid_type?(key)
click to toggle source
Check if provided key is a supported key type
@param [Symbol] key Key type to check @return [Boolean] key type is supported
# File lib/vagrant/util/keypair.rb, line 24 def self.valid_type?(key) VALID_TYPES.keys.include?(key) end