如何使用 Apache SSHD 进入被动模式
How to enter into passive mode with Apache SSHD
我有以下代码使用 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 中的 active/passive 模式完全不同。
active/passive模式与FTP协议有区别,因为它使用单独的数据连接。在主动模式下,服务器发起数据连接。在被动模式下,客户端发起连接。
有关详细信息,请参阅我在 FTP connection modes 上的文章。
SFTP 中没有单独的数据连接,因此没有理由使用 active/passive 模式。
我有以下代码使用 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 中的 active/passive 模式完全不同。
active/passive模式与FTP协议有区别,因为它使用单独的数据连接。在主动模式下,服务器发起数据连接。在被动模式下,客户端发起连接。
有关详细信息,请参阅我在 FTP connection modes 上的文章。
SFTP 中没有单独的数据连接,因此没有理由使用 active/passive 模式。