ssh - Android cannot connect to a sftp server using JSCH - Stack Overflow

I'm trying to upload a file to a sftp server from an Android App using JSCH v. 0.1.55. However, I

I'm trying to upload a file to a sftp server from an Android App using JSCH v. 0.1.55. However, I get an exception during the connection.

com.jcraft.jsch.JSchException: java.lang.InstantiationException: java.lang.Class<com.jcraft.jsch.UserAuthNone> has no zero argument constructor
    at com.jcraft.jsch.Session.connect(Session.java:393)
    at com.jcraft.jsch.Session.connect(Session.java:183)
Caused by: java.lang.InstantiationException: java.lang.Class<com.jcraft.jsch.UserAuthNone> has no zero argument constructor
    at java.lang.Class.newInstance(Native Method)
    at com.jcraft.jsch.Session.connect(Session.java:390)

This error seems to happen when the password is not set, but I checked with the debugger and all info are correct. Also, I can conect using FileZilla. Here is the code. The error is when executing session.connect();

Session session = null;
Channel channel = null;
try {
    JSch jsch = new JSch();
    session = jsch.getSession(user, host, port);
    session.setPassword(password);

    Properties config = new Properties();
    config.put("StrictHostKeyChecking", "no");
    config.put("PreferredAuthentications", "password");
    session.setConfig(config);

    session.connect();

    // Code uploading the file

} catch (Exception ex) {
    ex.printStackTrace();
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744658595a4586322.html

相关推荐

  • ssh - Android cannot connect to a sftp server using JSCH - Stack Overflow

    I'm trying to upload a file to a sftp server from an Android App using JSCH v. 0.1.55. However, I

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>