use of org.apache.sshd.server.Command in project pentaho-kettle by pentaho.
the class SftpServer method createSshServer.
private SshServer createSshServer(int port, String homeDir, String hostKeyPath) {
SshServer server = SshServer.setUpDefaultServer();
server.setHost("localhost");
server.setPort(port);
server.setFileSystemFactory(new VirtualFileSystemFactory(homeDir));
server.setSubsystemFactories(Collections.<NamedFactory<Command>>singletonList(new SftpSubsystem.Factory()));
server.setCommandFactory(new ScpCommandFactory());
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKeyPath));
server.setPasswordAuthenticator(this);
return server;
}
use of org.apache.sshd.server.Command in project camel by apache.
the class ScpServerTestSupport method startSshd.
protected boolean startSshd() {
sshd = SshServer.setUpDefaultServer();
sshd.setPort(getPort());
sshd.setKeyPairProvider(new FileKeyPairProvider(new String[] { "src/test/resources/hostkey.pem" }));
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
@Override
public boolean authenticate(String username, String password, ServerSession session) {
// dummy authentication: allow any user whose password is the same as the username
return username != null && username.equals(password);
}
});
sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
@Override
public boolean authenticate(String username, PublicKey key, ServerSession session) {
return true;
}
});
try {
sshd.start();
return true;
} catch (IOException e) {
LOG.info("Failed to start ssh server.", e);
}
return false;
}
use of org.apache.sshd.server.Command in project spring-integration by spring-projects.
the class SftpSessionFactoryTests method createServerAndClient.
private DefaultSftpSessionFactory createServerAndClient(SshServer server) throws IOException {
server.setPublickeyAuthenticator((username, key, session) -> true);
server.setPort(0);
server.setSubsystemFactories(Collections.<NamedFactory<Command>>singletonList(new SftpSubsystemFactory()));
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser")));
server.start();
DefaultSftpSessionFactory f = new DefaultSftpSessionFactory();
f.setHost("localhost");
f.setPort(server.getPort());
f.setUser("user");
Resource privateKey = new ClassPathResource("id_rsa");
f.setPrivateKey(privateKey);
return f;
}
use of org.apache.sshd.server.Command 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();
}
Aggregations