You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We did the basic setup for apache mina sshd server and set the FileSystemFactory of sshd (Ex: sshd.setFileSystemFactory(new SftpClientFileSystemFactory());) to connect to remote sftp server. Its working fine with one connection but when we tried to attempt multiple connection using same user it throws FileSystemAlreadyExistsException.
Sample code from custom SftpClientFileSystemFactory
public class SftpClientFileSystemFactory implements FileSystemFactory {
private static final Logger logger = LoggerFactory.getLogger(SftpClientFileSystemFactory.class.getName());
public SftpClientFileSystemFactory() {
}
public Path getUserHomeDir(SessionContext session) throws IOException {
return null;
}
public FileSystem createFileSystem(SessionContext session) throws IOException {
String username = session.getUsername();
FileSystem fs = null;
URI uri = SftpFileSystemProvider.createFileSystemURI("sftp.remote.test", 2022, "user", "pass"); //Example
try {
fs = FileSystems.newFileSystem(uri, Collections.<String, Object>emptyMap());
} catch (IOException e) {
logger.error("An error occurred while creating the file system or walking the file tree", e);
}
return fs;
}
Description
We did the basic setup for apache mina sshd server and set the FileSystemFactory of sshd (Ex: sshd.setFileSystemFactory(new SftpClientFileSystemFactory());) to connect to remote sftp server. Its working fine with one connection but when we tried to attempt multiple connection using same user it throws FileSystemAlreadyExistsException.
Sample code from custom SftpClientFileSystemFactory
public class SftpClientFileSystemFactory implements FileSystemFactory {
private static final Logger logger = LoggerFactory.getLogger(SftpClientFileSystemFactory.class.getName());
}
sshd server config
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(22);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
sshd.setPasswordAuthenticator((username, password, session) -> {
return true;
});
sshd.setPublickeyAuthenticator((username, key, session) -> {
return true;
});
sshd.setFileSystemFactory(new SftpClientFileSystemFactory());
sshd.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory()));
sshd.start();
Motivation
Wanted to check if this functionality exists or its not valid.
Alternatives considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: