# AuthPublickey (sshj 0.4.1 API)
Date: 2011-06-19

## net.schmizz.sshj.userauth.method
Class AuthPublickey

    java.lang.Object
      net.schmizz.sshj.userauth.method.AbstractAuthMethod
          net.schmizz.sshj.userauth.method.KeyedAuthMethod
              net.schmizz.sshj.userauth.method.AuthPublickey

All Implemented Interfaces:
  SSHPacketHandler, AuthMethod

    public class AuthPublickey

extends KeyedAuthMethod

Implements the `"publickey"` SSH authentication method.

Requesteing authentication with this method first sends a "feeler" request with just the public key, and if the server responds with `SSH_MSG_USERAUTH_PK_OK` indicating that the key is acceptable, it proceeds to send a request signed with the private key. Therefore, private keys are not requested from the associated `KeyProvider` unless needed.

Field Summary

Fields inherited from class net.schmizz.sshj.userauth.method.KeyedAuthMethod
`kProv`

Fields inherited from class net.schmizz.sshj.userauth.method.AbstractAuthMethod
`log, params`

Constructor Summary
`AuthPublickey(KeyProvider kProv)` Initialize this method with the provider for public and private key.

Method Summary
`protected SSHPacket` `buildReq()` Builds a feeler request (sans signature).
`void` `handle(Message cmd, SSHPacket buf)` Internal use.

Methods inherited from class net.schmizz.sshj.userauth.method.KeyedAuthMethod
`putPubKey, putSig`

Methods inherited from class net.schmizz.sshj.userauth.method.AbstractAuthMethod
`getName, init, makeAccountResource, request, shouldRetry`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AuthPublickey

    public AuthPublickey(KeyProvider kProv)

  Initialize this method with the provider for public and private key.

Method Detail

### handle

    public void handle(Message cmd,
                       SSHPacket buf)
                throws UserAuthException,
                       TransportException

  Internal use.

  Specified by:
    `handle` in interface `SSHPacketHandler`
  Overrides:
    `handle` in class `AbstractAuthMethod`
  Parameters:
    `cmd` - the SSH `message identifier`
    `buf` - `SSHPacket` containing rest of the request
  Throws:
    `UserAuthException`
    `TransportException`

### buildReq

    protected SSHPacket buildReq()
                          throws UserAuthException

  Builds a feeler request (sans signature).

  Overrides:
    `buildReq` in class `AbstractAuthMethod`
  Throws:
    `UserAuthException`

Copyright © 2009-2011. All Rights Reserved.