Class AuthAgent
java.lang.Object
net.schmizz.sshj.userauth.method.AbstractAuthMethod
net.schmizz.sshj.userauth.method.KeyedAuthMethod
com.hierynomus.sshj.userauth.agent.AuthAgent
- All Implemented Interfaces:
SSHPacketHandler,AuthMethod
The
"publickey" authentication method backed by an SSH agent, for a single agent identity.
It behaves exactly like AuthPublickey - send the public
key, and on SSH_MSG_USERAUTH_PK_OK send a signed request - except the signature is
produced by the AgentProxy (which drives the hardware, PIN and touch) and used verbatim.
This is how FIDO/U2F security keys (sk-*) authenticate: the agent returns a complete
signature with the security-key flags and counter already appended.
Use fromIdentities(AgentProxy) to turn every identity the agent holds into a method:
try (AgentProxy agent = AgentProxy.fromEnvironment()) {
ssh.auth(username, AuthAgent.fromIdentities(agent));
}
-
Field Summary
Fields inherited from class net.schmizz.sshj.userauth.method.KeyedAuthMethod
kProvFields inherited from class net.schmizz.sshj.userauth.method.AbstractAuthMethod
log, params -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SSHPacketbuildReq()Builds aSSHPacketcontaining the fields common to all authentication method.static List<AuthMethod>fromIdentities(AgentProxy agent) Build oneAuthAgentmethod per identity the agent currently holds, ready to hand toSSHClient.auth(String, Iterable).voidDelegate handling of some SSH packet to this object.protected SSHPacketMethods inherited from class net.schmizz.sshj.userauth.method.KeyedAuthMethod
getPublicKeyAlgorithm, putSig, shouldRetryMethods inherited from class net.schmizz.sshj.userauth.method.AbstractAuthMethod
getName, init, makeAccountResource, request, setLoggerFactory
-
Constructor Details
-
AuthAgent
-
-
Method Details
-
fromIdentities
Build oneAuthAgentmethod per identity the agent currently holds, ready to hand toSSHClient.auth(String, Iterable).- Throws:
IOException
-
handle
Description copied from interface:SSHPacketHandlerDelegate handling of some SSH packet to this object.- Specified by:
handlein interfaceSSHPacketHandler- Overrides:
handlein classAbstractAuthMethod- Parameters:
cmd- the SSHmessage identifierbuf-SSHPacketcontaining rest of the request- Throws:
UserAuthExceptionTransportException
-
buildReq
Description copied from class:AbstractAuthMethodBuilds aSSHPacketcontaining the fields common to all authentication method. Method-specific fields can further be put into this buffer.- Overrides:
buildReqin classAbstractAuthMethod- Throws:
UserAuthException
-
putPubKey
- Overrides:
putPubKeyin classKeyedAuthMethod- Throws:
UserAuthException
-