module CORL::Mixin::Action::Keypair
Public Instance Methods
keypair(reset = false, warn = true)
click to toggle source
# File lib/core/mixin/action/keypair.rb 81 def keypair(reset = false, warn = true) 82 if reset || ! @keypair 83 if settings[:private_key] 84 key_options = { :private_key => private_key } 85 else 86 key_options = {} 87 if settings[:require_password] 88 key_password = password('SSH') 89 if key_password 90 key_options[:passphrase] = key_password 91 else 92 warn('no_password') if warn 93 return nil 94 end 95 end 96 end 97 myself.keypair = key_options 98 end 99 @keypair 100 end
keypair=(options)
click to toggle source
# File lib/core/mixin/action/keypair.rb 69 def keypair=options 70 config = Config.ensure(options).defaults({ 71 :type => settings[:key_type].to_s.upcase, 72 :bits => settings[:key_bits], 73 :comment => settings[:key_comment] 74 }) 75 @keypair = Util::SSH.generate(config) 76 settings.import({ :keypair => @keypair }) 77 end
keypair_clean()
click to toggle source
# File lib/core/mixin/action/keypair.rb 58 def keypair_clean 59 remove(keypair_ignore) 60 end
keypair_config()
click to toggle source
# File lib/core/mixin/action/keypair.rb 10 def keypair_config 11 register_str :private_key, nil, 'corl.core.mixin.action.keypair.options.private_key' do |value| 12 success = true 13 if value 14 file = File.expand_path(value) 15 if File.exists?(file) 16 unless Util::SSH.generate({ :private_key => file }) 17 warn('corl.core.mixin.action.keypair.errors.private_key_parse_error', { :value => file }) 18 success = false 19 end 20 else 21 warn('corl.core.mixin.action.keypair.errors.private_key_not_found', { :value => file }) 22 success = false 23 end 24 end 25 success 26 end 27 28 register_bool :require_password, false, 'corl.core.mixin.action.keypair.options.require_password' 29 30 register_str :key_type, 'RSA', 'corl.core.mixin.action.keypair.options.key_type' do |value| 31 key_type_choices = [ 'RSA', 'DSA' ] 32 unless key_type_choices.include?(value.to_s.upcase) 33 warn('corl.core.mixin.action.keypair.errors.key_type', { :value => value, :choices => key_type_choices }) 34 next false 35 end 36 true 37 end 38 register_int :key_bits, 2048, 'corl.core.mixin.action.keypair.options.key_bits' do |value| 39 unless value >= 2048 40 warn('corl.core.mixin.action.keypair.errors.key_bits', { :value => value, :required => 2048 }) 41 next false 42 end 43 true 44 end 45 register_str :key_comment, '', 'corl.core.mixin.action.keypair.options.key_comment' 46 47 config_subset(keypair_ignore) 48 end
keypair_ignore()
click to toggle source
# File lib/core/mixin/action/keypair.rb 52 def keypair_ignore 53 [ :require_password, :key_type, :key_bits, :key_comment ] 54 end