Class: Validator
- Inherits:
-
Object
- Object
- Validator
- Defined in:
- lib/direct_ssh/validator.rb
Instance Attribute Summary collapse
-
#direct ⇒ Object
readonly
Returns the value of attribute direct.
Instance Method Summary collapse
-
#initialize ⇒ Validator
constructor
A new instance of Validator.
- #start(host, user, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Validator
Returns a new instance of Validator.
11 12 13 |
# File 'lib/direct_ssh/validator.rb', line 11 def initialize @direct = true end |
Instance Attribute Details
#direct ⇒ Object (readonly)
Returns the value of attribute direct.
9 10 11 |
# File 'lib/direct_ssh/validator.rb', line 9 def direct @direct end |
Instance Method Details
#start(host, user, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/direct_ssh/validator.rb', line 15 def start(host, user, ={}) [:auth_methods] = ["publickey"] return Net::SSH.start(host, user, ) rescue Net::SSH::AuthenticationFailed @direct = false 3.times { [:password] = ask("#{user}@#{host}'s password: ") { |q| q.echo = false } begin [:auth_methods] = ["password"] return Net::SSH.start(host, user, ) rescue Net::SSH::AuthenticationFailed end } raise Net::SSH::AuthenticationFailed, 'Permission denied, please try again.' end |