使用JSch SFTP客户端连接到FileZilla服务器时出错 [英] Error to connect to FileZilla server using JSch SFTP client

查看:125
本文介绍了使用JSch SFTP客户端连接到FileZilla服务器时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用localhost配置在SFTP上进行连接,但是出现以下错误.但是,当我在FilleZilla上使用相同的配置时,它可以完美运行...

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...

在FilleZilla服务器上:

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.

这是Java中的错误:

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)

这是我的Java代码:

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;

推荐答案

FileZilla是FTP服务器,而不是SFTP服务器.

FileZilla is FTP server, not SFTP server.

JSch是SFTP客户端.

JSch is SFTP client.

您不能使用JSch连接到FileZilla服务器.

You cannot use JSch to connect to FileZilla server.

您必须使用FTP库,例如 Apache Commont Net FTPClient .

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

这篇关于使用JSch SFTP客户端连接到FileZilla服务器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆