我有以下代码使用 Apache Mina SSHD 创建远程 ChannelSubsystem
(FTP 客户端):
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();
如何通过 ChannelSubsystem
向远程 FTP 站点发送命令以进入被动模式?
最佳答案
您正在使用 SSH/SFTP 连接,而不是 FTP。
SFTP 中没有主动/被动模式。
主动/被动模式与FTP协议(protocol)是有区别的,因为它使用单独的数据连接。在主动模式下,服务器发起数据连接。在被动模式下,客户端发起连接。
请参阅我关于 FTP connection modes 的文章了解详情。
SFTP 中没有单独的数据连接,因此没有理由采用主动/被动模式。
关于java - 如何使用 Apache SSHD 进入被动模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32324150/