How can I enable passive mode while using JSch as SFTP client?

12.3k Views Asked by At

I'm using JSch as SFTP client and now I need to enable passive mode because of some limitation of security.

But I can not found a way to enable passive mode.

Can somebody tell me how to do this?

2

There are 2 best solutions below

0
On

SFTP protocol has no passive mode - it runs everything (commands and data) over one established connection.

0
On

"Passive mode" is a specialty of the FTP protocol.

In normal FTP mode for each individual file the client listens on a port and the server has to connect to this. As many firewalls support only outgoing connections, there was added the passive mode - here the client connects to the server for the individual files.

SFTP is a totally independent protocol from FTP - it also supports file transfer over a network, but this is already the end of the similarities. Everything (both commands and data) is transferred in the same SFTP channel, which in turn usually (and certainly if using JSch), is part of an SSH connection, which is transported over TCP. This single TCP connection is always started by the client, thus there should be no problem with firewalls, if they don't block SSH completely.

If you have a problem with your "limitation of security" (whatever this it), it certainly does not depend on SFTP modes here. If you add the necessary information to your question, we can maybe help you here.