Search in sources :

Example 6 with SftpSubsystemFactory

use of org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory in project spring-integration by spring-projects.

the class SftpTestSupport method createServer.

@BeforeClass
public static void createServer() throws Exception {
    server = SshServer.setUpDefaultServer();
    server.setPasswordAuthenticator((username, password, session) -> true);
    server.setPort(0);
    server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser")));
    server.setSubsystemFactories(Collections.<NamedFactory<Command>>singletonList(new SftpSubsystemFactory()));
    server.setFileSystemFactory(new VirtualFileSystemFactory(remoteTemporaryFolder.getRoot().toPath()));
    server.start();
    port = server.getPort();
}
Also used : SimpleGeneratorHostKeyProvider(org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider) SftpSubsystemFactory(org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory) Command(org.apache.sshd.server.Command) VirtualFileSystemFactory(org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 7 with SftpSubsystemFactory

use of org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory in project wildfly-camel by wildfly-extras.

the class EmbeddedSSHServer method setupSftp.

public void setupSftp() {
    this.sshServer.setCommandFactory(new ScpCommandFactory());
    this.sshServer.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory()));
}
Also used : ScpCommandFactory(org.apache.sshd.server.scp.ScpCommandFactory) SftpSubsystemFactory(org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory)

Example 8 with SftpSubsystemFactory

use of org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory in project structr by structr.

the class SSHService method getSubsystems.

// ----- private methods -----
private List<NamedFactory<org.apache.sshd.server.Command>> getSubsystems() {
    final List<NamedFactory<org.apache.sshd.server.Command>> list = new LinkedList<>();
    // sftp
    final SftpSubsystemFactory factory = new SftpSubsystemFactory();
    list.add(factory);
    factory.addSftpEventListener(this);
    return list;
}
Also used : SftpSubsystemFactory(org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory) NamedFactory(org.apache.sshd.common.NamedFactory) LinkedList(java.util.LinkedList)

Example 9 with SftpSubsystemFactory

use of org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory in project AmazeFileManager by TeamAmaze.

the class AbstractSftpServerTest method createSshServer.

protected final int createSshServer(FileSystemFactory fileSystemFactory, int startPort) throws IOException {
    server = SshServer.setUpDefaultServer();
    server.setFileSystemFactory(fileSystemFactory);
    server.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
    server.setHost("127.0.0.1");
    server.setKeyPairProvider(hostKeyProvider);
    server.setCommandFactory(new ScpCommandFactory());
    server.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory()));
    server.setPasswordAuthenticator(((username, password, session) -> username.equals("testuser") && password.equals("testpassword")));
    try {
        server.setPort(startPort);
        server.start();
        return startPort;
    } catch (BindException ifPortIsUnavailable) {
        return createSshServer(fileSystemFactory, startPort + 1);
    }
}
Also used : KeyUtils(org.apache.sshd.common.config.keys.KeyUtils) VirtualFileSystemFactory(org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory) KITKAT(android.os.Build.VERSION_CODES.KITKAT) Arrays(java.util.Arrays) SshServer(org.apache.sshd.server.SshServer) BeforeClass(org.junit.BeforeClass) JELLY_BEAN(android.os.Build.VERSION_CODES.JELLY_BEAN) Environment(android.os.Environment) P(android.os.Build.VERSION_CODES.P) AcceptAllPublickeyAuthenticator(org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) IOException(java.io.IOException) BindException(java.net.BindException) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) ShadowMultiDex(com.amaze.filemanager.shadows.ShadowMultiDex) Paths(java.nio.file.Paths) TestKeyProvider(com.amaze.filemanager.filesystem.ssh.test.TestKeyProvider) SftpSubsystemFactory(org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory) After(org.junit.After) FileSystemFactory(org.apache.sshd.common.file.FileSystemFactory) ScpCommandFactory(org.apache.sshd.server.scp.ScpCommandFactory) Before(org.junit.Before) ScpCommandFactory(org.apache.sshd.server.scp.ScpCommandFactory) SftpSubsystemFactory(org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory) BindException(java.net.BindException)

Aggregations

SftpSubsystemFactory (org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory)9 File (java.io.File)6 SimpleGeneratorHostKeyProvider (org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider)6 VirtualFileSystemFactory (org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory)5 Command (org.apache.sshd.server.Command)5 SshServer (org.apache.sshd.server.SshServer)3 ScpCommandFactory (org.apache.sshd.server.scp.ScpCommandFactory)3 LsEntry (com.jcraft.jsch.ChannelSftp.LsEntry)2 PublicKey (java.security.PublicKey)2 NamedFactory (org.apache.sshd.common.NamedFactory)2 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 JELLY_BEAN (android.os.Build.VERSION_CODES.JELLY_BEAN)1 KITKAT (android.os.Build.VERSION_CODES.KITKAT)1 P (android.os.Build.VERSION_CODES.P)1 Environment (android.os.Environment)1 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)1 TestKeyProvider (com.amaze.filemanager.filesystem.ssh.test.TestKeyProvider)1 ShadowMultiDex (com.amaze.filemanager.shadows.ShadowMultiDex)1