sshj icon indicating copy to clipboard operation
sshj copied to clipboard

Whether mixed password authentication and public key authentication are supported

Open Bamboo-devops opened this issue 3 years ago • 5 comments

I have a project that requires both password and public key authentication, please tell me how to achieve it. Is there an example

Bamboo-devops avatar Sep 14 '22 07:09 Bamboo-devops

The SSHClient.auth() method supports the ability to provide multiple types of authentication methods, including password and public key authentication.

Apache NiFi has components that implement this approach. The StandardSSHClientProvider class builds a list of AuthMethod objects based on external configuration.

exceptionfactory avatar Sep 15 '22 13:09 exceptionfactory

@Bamboo-devops This should indeed work by configuring multiple auth methods in the right order. SSHJ can then first do password authentication and if that partially succeeds additionally do the Pubkey authentication to fully authenticate the user. If this answers your question, please close the issue.

hierynomus avatar Sep 17 '22 05:09 hierynomus

got it.thanks all。

Bamboo-devops avatar Sep 20 '22 10:09 Bamboo-devops

@hierynomus @exceptionfactory Sorry to revive a dead thread, but it actually talks about something I was looking for almost exactly. We're actually using an FTP processor from Apache Nifi and ran into an issue with auth methods. Our issue is that the AuthMethods ordering seems to matter. That's not the case for most ssh clients and it's causing us trouble connecting to some FTP servers as some have different AuthenticationMethods configured in their sshd_config. They're similar, but the order can vary and we can't change them on the server side. Is it possible to make these checks order agnostic? For instance, if you use the openssh client's PreferredAuthentications options, it doesn't matter if you do "password,publickey" or "publickey,password".

jamespowenjr avatar Sep 23 '22 18:09 jamespowenjr

Can you check whether https://github.com/hierynomus/sshj/pull/820 works for you?

hierynomus avatar Sep 23 '22 20:09 hierynomus