Sha256: afecb9ebdfad0ca8098534ced27c422014caece6ea8af442ab9d527c79894162

Contents?: true

Size: 1.25 KB

Versions: 145

Compression:

Stored size: 1.25 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" }
                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

145 entries across 115 versions & 12 rubygems

Version Path
tpkg-2.3.5 lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/password.rb
tpkg-2.3.4 lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.10 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.11 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.12 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.13 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.14 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.15 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.16 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.17 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.5 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.6 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.7 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
auser-poolparty-1.3.8 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
ddollar-net-ssh-2.0.1 lib/net/ssh/authentication/methods/password.rb
fairchild-poolparty-1.3.17 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
fairchild-poolparty-1.3.5 vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb
jayniz-net-ssh-2.0.15 lib/net/ssh/authentication/methods/password.rb
kjvarga-net-ssh-2.0.12 lib/net/ssh/authentication/methods/password.rb
net-ssh-net-ssh-2.0.12 lib/net/ssh/authentication/methods/password.rb