Class: EventMachine::Ssh::AuthenticationSession

Inherits:
Net::SSH::Authentication::Session
  • Object
show all
Includes:
Log
Defined in:
lib/em-ssh/authentication-session.rb

Instance Method Summary collapse

Methods included from Log

#debug, #error, #fatal, #info, #log, #warn

Instance Method Details

#authenticate(*args) ⇒ Object



6
7
8
9
# File 'lib/em-ssh/authentication-session.rb', line 6

def authenticate(*args)
  debug { "authenticate(#{args.join(", ")})" }
  super(*args)
end

#next_messageObject

Returns once an acceptable auth packet is received.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/em-ssh/authentication-session.rb', line 12

def next_message
  packet = transport.next_message

  case packet.type
  when USERAUTH_BANNER
    info { packet[:message] }
    transport.fire(:auth_banner, packet[:message])
    return next_message
  when USERAUTH_FAILURE
    @allowed_auth_methods = packet[:authentications].split(/,/)
    debug { "allowed methods: #{packet[:authentications]}" }
    return packet

  when USERAUTH_METHOD_RANGE, SERVICE_ACCEPT
    return packet

  when USERAUTH_SUCCESS
    transport.hint :authenticated
    return packet

  else
    raise SshError, "unexpected message #{packet.type} (#{packet})"
  end
end