class Validator
Attributes
direct[R]
Public Class Methods
new()
click to toggle source
# File lib/direct_ssh/validator.rb, line 11 def initialize @direct = true end
Public Instance Methods
start(host, user, options={})
click to toggle source
# File lib/direct_ssh/validator.rb, line 15 def start(host, user, options={}) options[:auth_methods] = ["publickey"] return Net::SSH.start(host, user, options) rescue Net::SSH::AuthenticationFailed @direct = false 3.times { options[:password] = ask("#{user}@#{host}'s password: ") { |q| q.echo = false } begin options[:auth_methods] = ["password"] return Net::SSH.start(host, user, options) rescue Net::SSH::AuthenticationFailed end } raise Net::SSH::AuthenticationFailed, 'Permission denied, please try again.' end