SFTP connection with FTPSClient is failing

二次信任 提交于 2020-01-11 08:00:30

问题


Below code I'm trying to connect SFTP host using FTPSClient. Instead of FTP client, I'm using FTPSClient to connect. But I'm facing issue to connect.

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:


FTPS is not SFTP.

You cannot use Apache Commons Net FTPS client FTPSClient to connect to SFTP port 22. That's a completely different protocol.

You have to use a different library. The most commonly used SFTP library for Java is JSch.

See also Secure FTP with org.apache.commons.net.ftp.FTPClient.



来源:https://stackoverflow.com/questions/44306082/sftp-connection-with-ftpsclient-is-failing

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