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