tomaswolf commented on issue #748: URL: https://github.com/apache/mina-sshd/issues/748#issuecomment-2850236217
There is no API for this. Storing a single public key also might not be good enough: depending on how your server is configured, a single public key might not be enough to authenticate. For instance, if CoreModuleProperties.AUTH_METHODS is set to "publickey,publickey" two different public keys are needed to complete authentication. Or "publickey,password" might require a public key and a password. Or "publickey,password,publickey" would need a key, a password, and a second (and different) key. Also, there is always a user name with an authentication request. It's not quite clear to me what you are trying to do; perhaps something like the way GitHub handles SSH authentications: the user name is always "git", but the key used then identifies the actual GitHub account that logged in? (So there must be a database of public keys somewhere, and each public key is linked to exactly one account.) In any case: if you know that a single public key is sufficient for authentication and you want to access that key later from the session, then I would suggest storing that key as an attribute on the session. Declare an `AttributeKey` somewhere: ``` import org.apache.sshd.common.AttributeRepository.AttributeKey; ... public static final AttributeKey<PublicKey> USER_KEY = new AttributeKey<>(); ``` In your pubkey authenticator, you could set that attribute via `session.setAttribute(USER_KEY, key)` and retrieve anywhere else via `session.getAttribute(USER_KEY)`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org