0

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);
}
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Shailu
  • 163
  • 1
  • 5
  • 16

1 Answers1

4

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992