与FTPSClient的SFTP连接失败

时间:2017-06-01 11:18:08

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

在代码下面,我尝试使用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);
}

1 个答案:

答案 0 :(得分:4)

FTPS is not SFTP

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

您必须使用其他库。最常用的Java SFTP库是JSch

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

相关问题