SFTP connection through Java asking for weird authentication

前端 未结 3 400
执念已碎
执念已碎 2020-12-13 00:04

So I\'m writing a little program that needs to connect to a remote server through SFTP, pull down a file, and then processes the file. I came across JSch through some answer

3条回答
  •  有刺的猬
    2020-12-13 00:41

    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.

提交回复
热议问题