I'm getting the same error when I use linux based sftp client to connect to
mina sshd server.
I'm using async authentication. And, only the first attempt to login
fails(even though I get authentication success in my logs)
Here are the logs I can see in my application:
[Thread-4] INFO org.apache.sshd.server.session.ServerUserAuthService -
Session admin@/0:0:0:0:0:0:0:1:57453 authenticated
[sshd-SshServer[181e731e]-nio2-thread-6] WARN
org.apache.sshd.server.session.ServerSessionImpl -
exceptionCaught(ServerSessionImpl[admin@/0:0:0:0:0:0:0:1:57453])[state=Opened]
IllegalStateException: No current authentication mechanism for
cmd=SSH_MSG_CHANNEL_OPEN
val userAuthFactories = new util.ArrayList[NamedFactory[UserAuth]]()
userAuthFactories.add(new UserAuthPasswordFactory())
val sshd: SshServer = SshServer.setUpDefaultServer()
sshd.setPort(1988)
sshd.setKeyPairProvider(new
SimpleGeneratorHostKeyProvider(Paths.get("/Users/sujeeva/a.ser")))
sshd.setUserAuthFactories(userAuthFactories)
sshd.setShellFactory(new InteractiveProcessShellFactory())
val factory = new SftpSubsystemFactory.Builder().build()
sshd.setSubsystemFactories(util.Arrays.asList(factory))
sshd.setCommandFactory((command: String) => {
println("SSH server received command " + command)
new InvertedShellWrapper(new ProcessShell(command))
})
sshd.setPasswordAuthenticator((username: String, password: String,
session: ServerSession) => {
async(1000, true)
})
def async(delay: Int, result: Boolean): Boolean = {
val auth = new AsyncAuthException
new Thread(() => doAsync(delay, result, auth)).start()
throw auth
}
private def doAsync(delay: Int, result: Boolean, auth:
AsyncAuthException): Unit = {
try
Thread.sleep(delay)
catch {
case ignore: InterruptedException =>
} finally auth.setAuthed(result)
}
--
Sent from:
http://apache-mina.10907.n7.nabble.com/Apache-MINA-User-Forum-f31345.html