Sha256: efbf509635cf3d2465c4ea847a705b3753dfbe83f53a5e76fdc3ab10e62b691c

Contents?: true

Size: 1.39 KB

Versions: 42

Compression:

Stored size: 1.39 KB

Contents

require 'net/ssh/errors'
require 'net/ssh/authentication/methods/abstract'

module Net
  module SSH
    module Authentication
      module Methods

        # Implements the "password" SSH authentication method.
        class Password < Abstract
          # Attempt to authenticate the given user for the given service. If
          # the password parameter is nil, this will never do anything except
          # return false.
          def authenticate(next_service, username, password=nil)
            return false unless password

            send_message(userauth_request(username, next_service, "password", false, password))
            message = session.next_message

            case message.type
              when USERAUTH_SUCCESS
                debug { "password succeeded" }
                return true
              when USERAUTH_FAILURE
                debug { "password failed" }

                raise Net::SSH::Authentication::DisallowedMethod unless
                  message[:authentications].split(/,/).include? 'password'

                return false
              when USERAUTH_PASSWD_CHANGEREQ
                debug { "password change request received, failing" }
                return false
              else
                raise Net::SSH::Exception, "unexpected reply to USERAUTH_REQUEST: #{message.type} (#{message.inspect})"
            end
          end
        end

      end
    end
  end
end

Version data entries

42 entries across 40 versions & 13 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/net-ssh-2.4.0/lib/net/ssh/authentication/methods/password.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/net-ssh-2.9.1/lib/net/ssh/authentication/methods/password.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/net-ssh-2.9.1/lib/net/ssh/authentication/methods/password.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/authentication/methods/password.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/authentication/methods/password.rb
net-ssh-2.9.1 lib/net/ssh/authentication/methods/password.rb
net-ssh-2.9.0 lib/net/ssh/authentication/methods/password.rb
net-ssh-2.8.0 lib/net/ssh/authentication/methods/password.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/authentication/methods/password.rb
net-ssh-2.7.0 lib/net/ssh/authentication/methods/password.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.7/lib/net/ssh/authentication/methods/password.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/authentication/methods/password.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.7/lib/net/ssh/authentication/methods/password.rb
net-ssh-2.6.8 lib/net/ssh/authentication/methods/password.rb
minmb-net-ssh-2.5.1 lib/net/ssh/authentication/methods/password.rb
vagrant-shell-0.2.6 vendor/bundle/gems/net-ssh-2.6.7/lib/net/ssh/authentication/methods/password.rb
vagrant-shell-0.2.5 vendor/bundle/gems/net-ssh-2.6.7/lib/net/ssh/authentication/methods/password.rb
net-ssh-2.6.7 lib/net/ssh/authentication/methods/password.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/net-ssh-2.2.2/lib/net/ssh/authentication/methods/password.rb
net-ssh-2.6.6 lib/net/ssh/authentication/methods/password.rb