private SshServer defaultSshServer() { SshServer sshServer = SshServer.setUpDefaultServer(); sshServer.setPort(randomPort()); ClassLoadableResourceKeyPairProvider fileKeyPairProvider = new ClassLoadableResourceKeyPairProvider(hostkey); sshServer.setKeyPairProvider(fileKeyPairProvider); sshServer.setPasswordAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) { return username.equals(password); } }); sshServer.setGSSAuthenticator(new BogusGSSAuthenticator()); sshServer.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory())); ScpCommandFactory commandFactory = new ScpCommandFactory(); commandFactory.setDelegateCommandFactory(new CommandFactory() { @Override public Command createCommand(String command) { return new ProcessShellFactory(command.split(" ")).create(); } }); sshServer.setCommandFactory(commandFactory); sshServer.setShellFactory(new ProcessShellFactory("ls")); return sshServer; }
protected void setupDummyShell(final boolean enable) { sshd.setShellFactory(enable ? new SecureShellFactory() : null); }
public MockSshServer enableShell() { logger.info("Mock SSH shell is enabled"); sshShell = new MockSshShell(); setDefaults(); sshServer.setShellFactory(this); return this; }
private void configureShellFactory(SshServer server) { Optional<String> baseDir = properties.getFiletransfer().isEnabled() ? Optional.of(properties.getFilesystem().getBase().getDir()) : Optional.empty(); server.setShellFactory(() -> sshSessionInstance(baseDir)); }
public EmbeddedSSHServer(Path homeDir, int port) { this.sshServer = SshServer.setUpDefaultServer(); this.sshServer.setPort(port); this.sshServer.setCommandFactory(new EchoCommandFactory()); this.sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider()); this.sshServer.setPasswordAuthenticator((username, password, serverSession) -> username.equals("admin") && password.equals("admin")); this.sshServer.setPublickeyAuthenticator((s, publicKey, serverSession) -> true); this.homeDir = homeDir; if (EnvironmentUtils.isWindows()) { sshServer.setShellFactory(new ProcessShellFactory(new String[] { "cmd.exe " })); } else { sshServer.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-s" })); } }
public EmbeddedSSHServer(Path homeDir, int port) { this.sshServer = SshServer.setUpDefaultServer(); this.sshServer.setPort(port); this.sshServer.setCommandFactory(new EchoCommandFactory()); this.sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider()); this.sshServer.setPasswordAuthenticator((username, password, serverSession) -> username.equals("admin") && password.equals("admin")); this.sshServer.setPublickeyAuthenticator((s, publicKey, serverSession) -> true); this.homeDir = homeDir; if (EnvironmentUtils.isWindows()) { sshServer.setShellFactory(new ProcessShellFactory(new String[] { "cmd.exe " })); } else { sshServer.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-s" })); } }
@Before public void setUp() throws Exception { sshServer = setupTestServer(); final byte[] msg = Files.readAllBytes( Paths.get(getClass().getResource("/big-msg.txt").toURI())); sshServer.setShellFactory(new Factory<Command>() { @Override public Command create() { return new FloodingAsyncCommand(msg, BIG_MSG_SEND_COUNT, END_FILE); } }); sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider()); sshServer.start(); port = sshServer.getPort(); }
@Before public void setUp() throws Exception { sshServer = setupTestServer(); final byte[] msg = Files.readAllBytes( Paths.get(getClass().getResource("/big-msg.txt").toURI())); sshServer.setShellFactory(new Factory<Command>() { @Override public Command create() { return new FloodingAsyncCommand(msg, BIG_MSG_SEND_COUNT, END_FILE); } }); sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider()); sshServer.start(); port = sshServer.getPort(); }
private void start() throws IOException { server = serverBuilder.get(); server.setPort(port); server.setHost(ip); server.setShellFactory(new ShellFactoryImpl(shell)); server.setCommandFactory(new ScpCommandFactory.Builder() .withDelegate(command -> new ShellCommand(execute, command)).build()); server.setSubsystemFactories(Collections.singletonList( new SftpSubsystemFactory.Builder().build() )); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider()); server.start(); }
private void start() throws IOException { server = serverBuilder.get(); server.setPort(port); server.setHost(ip); server.setShellFactory(new ShellFactoryImpl(shell)); server.setCommandFactory(new ScpCommandFactory.Builder() .withDelegate(command -> new ShellCommand(execute, command)).build()); server.setSubsystemFactories(Collections.singletonList( new SftpSubsystemFactory.Builder().build() )); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider()); server.start(); }
public void startServer(Integer timeout) throws Exception { if (server != null) { throw failure("Server already started"); } server = SshServer.setUpDefaultServer(); if (timeout != null) { server.getProperties().put(FactoryManager.AUTH_TIMEOUT, timeout.toString()); } server.setPort(5000); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath())); server.setPasswordAuthenticator((username, password, sess) -> authenticator.authenticate(username, password, sess)); server.setShellFactory(new EchoShellFactory()); server.setServiceFactories(Arrays.asList(ServerConnectionServiceFactory.INSTANCE, AsyncUserAuthServiceFactory.INSTANCE)); server.start(); }
@Before public void setUp() throws Exception { sshd = setupTestServer(); sshd.setShellFactory(new TestEchoShellFactory()); client = setupTestClient(); }
@Before public void setUp() throws Exception { sshd = setupTestServer(); sshd.setShellFactory(new TestEchoShellFactory()); client = setupTestClient(); }
@Before public void setUp() throws Exception { sshd = setupTestServer(); sshd.setShellFactory(new TestEchoShellFactory()); client = setupTestClient(); }
public static SshServer setupTestServer(Class<?> anchor) { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setKeyPairProvider(createTestHostKeyProvider(anchor)); sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE); sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE); sshd.setShellFactory(EchoShellFactory.INSTANCE); sshd.setCommandFactory(UnknownCommandFactory.INSTANCE); return sshd; }
public static SshServer setupTestServer(Class<?> anchor) { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setKeyPairProvider(createTestHostKeyProvider(anchor)); sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE); sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE); sshd.setShellFactory(EchoShellFactory.INSTANCE); sshd.setCommandFactory(UnknownCommandFactory.INSTANCE); return sshd; }
@Before public void setUp() throws Exception { sshd = setupTestServer(); PropertyResolverUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, TIMEOUT); sshd.setShellFactory(new TestEchoShellFactory()); sshd.start(); port = sshd.getPort(); }
@Before public void setUp() throws Exception { sshd = setupTestServer(); PropertyResolverUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, TIMEOUT); sshd.setShellFactory(new TestEchoShellFactory()); sshd.start(); port = sshd.getPort(); }
public static SshServer setupTestServer(Class<?> anchor) { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setKeyPairProvider(createTestHostKeyProvider(anchor)); sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE); sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE); sshd.setShellFactory(EchoShellFactory.INSTANCE); sshd.setCommandFactory(UnknownCommandFactory.INSTANCE); return sshd; }
@Before public void setUp() throws Exception { sshd = setupTestServer(); PropertyResolverUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, TIMEOUT); sshd.setShellFactory(new TestEchoShellFactory()); sshd.start(); port = sshd.getPort(); }