문제

I have an SFTP connection set up. I used WinCSP and Filezilla and the test server is working no problem. The java code is from the apache commons-net 2.0 and it gives me the unexpected error

Code

private String ftpServer="XXX.xx.x.XX";
private int ftpPort=99;
private String ftpUserName="myUserName";
private String ftpPassword="myPassword";

FTPSClient ftp = null;
        try{
            ftp = new FTPSClient();
            ftp.connect(hostname, port)
        } catch (Exception e){
           Logger.debug(e)
        }

Stacktrace

Server reply:SSH-2.0-WeOnlyDo-wodFTPD 2.3.6.165
org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:315)
    at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:364)
    at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:540)
    at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:167)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:178)
    at myHomeFtpService.getFtpConnection(HomeFtpService.java:40)
도움이 되었습니까?

해결책

Since you are connecting to an SSH server using FTP client. FTPS and SFTP are two different protocols.

Both WinSCP and Filezilla works fine because they supports SFTP.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top