SFTP connection through Java asking for weird authentication

给你一囗甜甜゛ 提交于 2019-11-28 16:50:32

Thought I'd post an answer here since in case anyone else ends up running into a similar issue. Turns out I am missing a piece of code that makes all the difference. I just needed to add

session.setConfig("PreferredAuthentications", 
                  "publickey,keyboard-interactive,password");

before

session.connect();

and everything works perfectly now.

While the solution in the self-accepted answer is correct, it lacks any explanation.

The problem is that the OP have a Kerberos/GSSAPI authentication set as the preferred (the JSch default). Yet OP does not seem to actually use/want it, as OP claims not to specify any username or password for the Kerberos prompts.

The solution is to remove the Kerberos/GSSAPI (gssapi-with-mic) from the list of preferred authentication methods:

session.setConfig(
    "PreferredAuthentications", 
    "publickey,keyboard-interactive,password");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!