I have a following code that creates remote ChannelSubsystem
(FTP client) using Apache Mina SSHD:
org.apache.sshd.client.channel.ChannelSubsystem c = session.createSubsystemChannel("sftp");
int authState = ClientSession.WAIT_AUTH;
while ((authState & ClientSession.WAIT_AUTH) != 0) {
System.out.println("authenticating...");
authFuture.addListener(new SshFutureListener<AuthFuture>()
{
@Override
public void operationComplete(AuthFuture arg0)
{
System.out.println("Authentication completed with " + ( arg0.isSuccess() ? "success" : "failure"));
}
});
authState = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0);
}
if ((authState & ClientSession.CLOSED) != 0) {
System.err.println("error");
System.exit(-1);
}
OpenFuture openFuture = c.open().await();
How can I via ChannelSubsystem
send a command to remote FTP site to enter to passive mode?
You are connecting using the SSH/SFTP, not the FTP.
There's nothing like the active/passive mode in the SFTP.
The active/passive mode is distinguished with the FTP protocol, because it uses a separate data connection. In the active mode, the server initiates the data connection. In the passive mode the client initiates the connection.
See my article on the FTP connection modes for details.
There's no separate data connection in the SFTP, hence no reason for the active/passive mode.