Issue in setting User auth factories in ClientSession
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 400
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 1
Description
Hello,
I am trying to setup a SSH configuration with Jumphost.
I am configuring my Jumphost userAuth in the Client . my jumphost can accept both password or private key authorization . so I am setting my client.setUserAuthFactories to accept both Public key and password.
And my SSH host will only accept password. so I was planning to set userAuthFactories in Session for the host.
**session.setUserAuthFactories(Collections.singletonList(UserAuthPasswordFactory.INSTANCE));**
But while executing i can see that authentication mechanisms is always set to the client inputs, the session inputs are not honored.
Can you please let me know if anything is missing in my code or understanding.
org.apache.sshd.client.SshClient client = org.apache.sshd.client.SshClient.setUpDefaultClient(); client.setForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
client.start();
client.setKeyIdentityProvider(
sessionContext -> Collections.singleton(------Jump Host Keypair -----));
client.setPasswordIdentityProvider(sessionContext -> Collections.singleton(---jump host password----));
**client.setUserAuthFactories(Collections.unmodifiableList(
Arrays.asList(UserAuthPublicKeyFactory.INSTANCE, UserAuthPasswordFactory.INSTANCE)));**
ClientSession session = client.connect(SSH_HOST_REFERENCE_NAME).verify(SERVER_ALIVE_INTERVAL).getSession(); **session.setUserAuthFactories(Collections.singletonList(UserAuthPasswordFactory.INSTANCE));**
session.setPasswordIdentityProvider(sessionContext -> Collections.singleton("default"));
**JumpHost Connection logs**
16:08:23.712 [sshd-SshClient[80503]-nio2-thread-7] DEBUG org.apache.sshd.client.session.ClientUserAuthService - processUserAuth(ClientSessionImpl[exxxxxx@test.server.se/10.0.0.215:22]) Received SSH_MSG_USERAUTH_FAILURE - partial=false, methods=publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
16:08:23.712 [sshd-SshClient[80503]-nio2-thread-7] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[exxxxxx@test.server.se/10.0.0.215:22]) starting authentication mechanisms: **client=[publickey, password],** server=[publickey, gssapi-keyex, gssapi-with-mic, password, keyboard-interactive]
16:08:23.712 [sshd-SshClient[80503]-nio2-thread-7] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[exxxxxx@test.server.se/10.0.0.215:22]) attempting method=publickey
**SSH Host connection logs**
16:08:24.270 [sshd-SshClient[80503]-nio2-thread-4] DEBUG org.apache.sshd.client.session.ClientUserAuthService - processUserAuth(ClientSessionImpl[admin@/127.0.0.1:43834]) Received SSH_MSG_USERAUTH_FAILURE - partial=false, methods=publickey,gssapi-keyex,gssapi-with-mic,password
16:08:24.270 [sshd-SshClient[80503]-nio2-thread-4] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[admin@/127.0.0.1:43834]) starting authentication mechanisms: **client=[publickey, password],** server=[publickey, gssapi-keyex, gssapi-with-mic, password]
16:08:24.270 [sshd-SshClient[80503]-nio2-thread-4] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[admin@/127.0.0.1:43834]) attempting method=publickey
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing ClientSession.setUserAuthFactories into ClientUserAuthService, using the two authentication log excerpts as the reproduction signal. Check how client- and session-level factories are selected during tryNext; done means a session configured with only UserAuthPasswordFactory uses password authentication instead of the client list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100