Error to connect to FileZilla server using JSch SFTP client

安稳与你 提交于 2019-12-23 04:50:38

问题


I'm trying to connect on SFTP using localhost configurations but I get the following error. But when I use the same configurations on FilleZilla it works perfect...

At FilleZilla server:

(000017)06/08/2019 09:26:20 - (not logged in) (127.0.0.1)> Connected on port 21, sending welcome message...
(000017)06/08/2019 09:26:20 - (not logged in) (127.0.0.1)> 220-FileZilla Server 0.9.60 beta
(000017)06/08/2019 09:26:20 - (not logged in) (127.0.0.1)> 220-written by Tim Kosse (tim.kosse@filezilla-project.org)
(000017)06/08/2019 09:26:20 - (not logged in) (127.0.0.1)> 220 Please visit https://filezilla-project.org/
(000017)06/08/2019 09:26:20 - (not logged in) (127.0.0.1)> SSH-2.0-JSCH-0.1.54
(000017)06/08/2019 09:26:20 - (not logged in) (127.0.0.1)> 500 Syntax error, command unrecognized.
(000017)06/08/2019 09:27:21 - (not logged in) (127.0.0.1)> 421 Login time exceeded. Closing control connection.
(000017)06/08/2019 09:27:21 - (not logged in) (127.0.0.1)> disconnected.

Here is the error in Java:

com.jcraft.jsch.JSchException: connection is closed by foreign host
    at com.jcraft.jsch.Session.connect(Session.java:269)
    at com.jcraft.jsch.Session.connect(Session.java:183)
    at br.com.wasys.nps.service.SftpService.test(SftpService.java:26)

Here is my Java code:

JSch jsch = new JSch();

Session session = jsch.getSession("test", "localhost", 21);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword("root");
session.connect();

ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = channel;

回答1:


FileZilla is FTP server, not SFTP server.

JSch is SFTP client.

You cannot use JSch to connect to FileZilla server.

You have to use an FTP library, like Apache Commont Net FTPClient.



来源:https://stackoverflow.com/questions/57376061/error-to-connect-to-filezilla-server-using-jsch-sftp-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!