You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Lyor Goldstein <lg...@apache.org> on 2020/05/22 15:42:09 UTC
Re: SCP commands redirect to SFTP subsystem
>> Now our requirement is once we use SCP from this filezila,
winscp,putty then also we need to call same class and same method as above
for SFTP.
Why would you want to do that ? SSHD supports SCP no need to go through
SFTP...
SshServer server = SshServer.setupDefaultServer();
...more initializations..
...initialize SFTP
server.setCommandFactory(new ScpCommandFactory());
Anyway here is a suggestion to get you on your way if you really (really,
really) need to do this
SshServer server = SshServer.setupDefaultServer();
...more initializations...
FileSystemFactory fsFactory = new FileSystemFactory() {
@Override
public FileSystem createFileSystem(Session session) throws IOException {
if (..whatever condition...) {
ClientSession client = ...establish a client session to
wherever you want using some SshClient...
// it does not have to be to the local server - it can be to
ANY server...
return SftpClientFactory.instance().createSftpFileSystem(
client )
} else {
return
NativeFileSystemFactory.INSTANCE.createFileSystem(session);
}
}
};
server.setFileSystemFactory(fsFactory);
Start with that.... there are more details - depending on what you want to
accomplish (which is not clear...) - ask for more help as you go along...