【问题标题】:SFTP connection with FTPSClient is failing与 FTPSClient 的 SFTP 连接失败
【发布时间】:2017-11-02 12:23:46
【问题描述】:

下面的代码我正在尝试使用FTPSClient 连接 SFTP 主机。我使用FTPSClient 代替FTP 客户端进行连接。但我面临连接问题。

public static void main(String[] args) throws SocketException, IOException {
        String host ="sftphost.com";
        String user = "abc";
        String pwd  = "pwd"
        final FTPSClient ftp = new FTPSClient();        
        System.out.println("host:"+host);
        ftp.connect(host,22);       
        int reply = ftp.getReplyCode();
        ftp.login(user, pwd);
}

【问题讨论】:

    标签: java sftp ftp-client ftps apache-commons-net


    【解决方案1】:

    FTPS is not SFTP.

    您不能使用 Apache Commons Net FTPS 客户端 FTPSClient 连接到 SFTP 端口 22。这是一个完全不同的协议。

    您必须使用不同的库。 Java 最常用的 SFTP 库是JSch

    另见Secure FTP with org.apache.commons.net.ftp.FTPClient

    【讨论】:

      猜你喜欢
      • 2017-05-24
      • 2019-09-23
      • 1970-01-01
      • 1970-01-01
      • 2017-12-29
      • 1970-01-01
      • 2020-12-25
      • 1970-01-01
      • 2020-02-05
      相关资源
      最近更新 更多