public void startServer() throws IOException { sshd = SshServer.setUpDefaultServer(); sshd.setHost("localhost"); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider()); //Accept all keys for authentication sshd.setPublickeyAuthenticator((s, publicKey, serverSession) -> true); //Allow username/password authentication using pre-defined credentials sshd.setPasswordAuthenticator((username, password, serverSession) -> this.username.equals(username) && this.password.equals(password)); //Setup Virtual File System (VFS) //Ensure VFS folder exists Path dir = Paths.get(getVirtualFileSystemPath()); Files.createDirectories(dir); sshd.setFileSystemFactory(new VirtualFileSystemFactory(dir.toAbsolutePath())); //Add SFTP support List<NamedFactory<Command>> sftpCommandFactory = new ArrayList<>(); sftpCommandFactory.add(new SftpSubsystemFactory()); sshd.setSubsystemFactories(sftpCommandFactory); sshd.start(); }
@Override protected void before() throws Throwable { sshd = SshServer.setUpDefaultServer(); sshd.setPort(findRandomOpenPortOnAllLocalInterfaces()); sshd.setKeyPairProvider( new ClassLoadableResourceKeyPairProvider(getClass().getClassLoader(), "server_key")); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory())); sshd.setUserAuthFactories(Collections.singletonList(new UserAuthPublicKeyFactory())); sshd.setHost("localhost"); sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE); sshd.setHostBasedAuthenticator(new StaticHostBasedAuthenticator(true)); VirtualFileSystemFactory fileSystemFactory = new VirtualFileSystemFactory(); fileSystemFactory.setDefaultHomeDir(currentFolder.get().toPath()); sshd.setFileSystemFactory(fileSystemFactory); sshd.start(); }
public void start() { sshServer = SshServer.setUpDefaultServer(); sshServer.setPort(port); sshServer.setHost("0.0.0.0"); final String basePath = new File(System.getProperty("user.dir")).getAbsolutePath(); if (SecurityUtils.isBouncyCastleRegistered()) { sshServer.setKeyPairProvider(new BouncyCastleGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".pem") .toPath())); } else { sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".ser"))); } sshServer.setShellFactory(new CrestComandsFactory(session, securityHandler)); sshServer.setPasswordAuthenticator(new PasswordAuthenticatorImpl(securityHandler)); try { sshServer.start(); } catch (IOException e) { e.printStackTrace(); } }
@Bean public SshServer sshServer() { SshServer server = SshServer.setUpDefaultServer(); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(properties.getHostKeyFile())); server.setPublickeyAuthenticator(RejectAllPublickeyAuthenticator.INSTANCE); server.setHost(properties.getHost()); String password = properties.getPassword(); if (password == null) { password = UUID.randomUUID().toString(); LOGGER.info(" --- Generating password for ssh connection: {}", password); } final String finalPassword = password; server.setPasswordAuthenticator((username, pass, serverSession) -> username.equals("user") && pass.equals(finalPassword)); server.setPort(properties.getPort()); server.setShellFactory(() -> shellCommandFactory); server.setCommandFactory(command -> shellCommandFactory); return server; }
protected SshServer buildSshServer() { SshServer sshd = setUpDefaultServer(); sshd.setPort(port); if (host != null) { sshd.setHost(host); } PropertyResolverUtils.updateProperty(sshd, IDLE_TIMEOUT, HOURS.toMillis(1)); sshd.addSessionListener(new SessionListener() { @Override public void sessionCreated(Session session) { } @Override public void sessionEvent(Session sesssion, Event event) { } @Override public void sessionException(Session session, Throwable t) { } @Override public void sessionClosed(Session session) { Groovysh shell = session.getAttribute(SHELL_KEY); if (shell != null) shell.getRunner().setRunning(false); } }); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("host.key").toPath())); configureAuthentication(sshd); sshd.setShellFactory(new GroovyShellFactory()); return sshd; }
public void start(Consumer<TtyConnection> factory, Consumer<Throwable> doneHandler) { server = SshServer.setUpDefaultServer(); server.setIoServiceFactoryFactory(new NettyIoServiceFactoryFactory(childGroup)); server.setPort(port); server.setHost(host); server.setKeyPairProvider(keyPairProvider); server.setPasswordAuthenticator(passwordAuthenticator); server.setShellFactory(() -> new TtyCommand(charset, factory)); try { server.start(); } catch (Exception e) { doneHandler.accept(e); return; } doneHandler.accept(null); }
public void start(Consumer<TtyConnection> factory, Consumer<Throwable> doneHandler) { server = SshServer.setUpDefaultServer(); server.setIoServiceFactoryFactory(new NettyIoServiceFactoryFactory(childGroup)); server.setPort(port); server.setHost(host); server.setKeyPairProvider(keyPairProvider); server.setPasswordAuthenticator(passwordAuthenticator); server.setShellFactory(() -> new TtyCommand(charset, factory)); try { server.start(); } catch (Exception e) { doneHandler.accept(e); return; } doneHandler.accept(null); }
private SshServer buildServer(Shell props) { SshServer server = SshServer.setUpDefaultServer(); server.setHost(props.getHost()); server.setPort(props.getPort()); configureAuthenticationPolicies(server, props); configureServer(server); return server; }
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(); }
/** * Construct ssh server thanks to ssh shell properties * * @return ssh server */ @Bean public SshServer sshServer() { SshServer server = SshServer.setUpDefaultServer(); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(properties.getHostKeyFile())); server.setPublickeyAuthenticator(RejectAllPublickeyAuthenticator.INSTANCE); server.setHost(properties.getHost()); server.setPasswordAuthenticator(passwordAuthenticator); server.setPort(properties.getPort()); server.setShellFactory(() -> shellCommandFactory); server.setCommandFactory(command -> shellCommandFactory); return server; }
})); nativeServer.setHost(options.getHost()); nativeServer.setPort(options.getPort()); nativeServer.setKeyPairProvider(provider);
sshd.setHost(inetSocketAddress.getHostName()); sshd.setPort(validateOrGetNew(inetSocketAddress.getPort()));
server.setHost(sshHost); server.setMacFactories(SshUtils.buildMacs(macs)); server.setCipherFactories(SshUtils.buildCiphers(ciphers));
server.setHost(sshHost); server.setMacFactories(SshUtils.buildMacs(macs)); server.setCipherFactories(SshUtils.buildCiphers(ciphers));
@Override protected void before() throws Throwable { sshd = SshServer.setUpDefaultServer(); sshd.setHost(InetAddress.getLoopbackAddress().getCanonicalHostName()); sshd.setPort(0); sshd.setForwardingFilter(AcceptAllForwardingFilter.INSTANCE);