You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "vorburger (via GitHub)" <gi...@apache.org> on 2025/05/01 19:03:59 UTC

[I] Allow obtaining the PublicKey from a ServerSession [mina-sshd]

vorburger opened a new issue, #748:
URL: https://github.com/apache/mina-sshd/issues/748

   ### Description
   
   It would be useful to be able to obtain the `java.security.PublicKey` from a `org.apache.sshd.server.session.ServerSession` (if one was used to authenticate).
   
   ### Motivation
   
   This seems useful to identify users.
   
   ### Alternatives considered
   
   I have written a `PublickeyAuthenticator` which uses an internal `Map<ServerSession, PublicKey> keys`, but it seems like a hack.
   
   ### Additional context
   
   Apologies if there is already an API to do this, but I couldn't find it.


-- 
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-unsubscribe@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


Re: [I] Allow obtaining the PublicKey from a ServerSession [mina-sshd]

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


Re: [I] Allow obtaining the PublicKey from a ServerSession [mina-sshd]

Posted by "vorburger (via GitHub)" <gi...@apache.org>.
vorburger commented on issue #748:
URL: https://github.com/apache/mina-sshd/issues/748#issuecomment-2910755549

   @tomaswolf Thank You! This tip was extremely helpful; I previously didn't really understand the _Attributes._
   
   https://github.com/enola-dev/enola/pull/1417 now uses this.


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


Re: [I] Allow obtaining the PublicKey from a ServerSession [mina-sshd]

Posted by "vorburger (via GitHub)" <gi...@apache.org>.
vorburger closed issue #748: Allow obtaining the PublicKey from a ServerSession
URL: https://github.com/apache/mina-sshd/issues/748


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org