public void setupSftpServer(){ SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(22); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new UserAuthNone.Factory()); sshd.setUserAuthFactories(userAuthFactories); sshd.setCommandFactory(new ScpCommandFactory()); List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>(); namedFactoryList.add(new SftpSubsystem.Factory()); sshd.setSubsystemFactories(namedFactoryList); try { sshd.start(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void start(Context context) { if (sshServer == null) { return; } List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new ShiroAuthFactory()); sshServer.setUserAuthFactories(userAuthFactories); LOGGER.info("Starting SSH server on port " + this.port); try { sshServer.start(); } catch (IOException e) { throw new PluginException("Unable to start SSH server on port " + this.port, e); } }
@Override public void start(Context context) { if (sshServer == null) { return; } List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new ShiroAuthFactory()); sshServer.setUserAuthFactories(userAuthFactories); LOGGER.info("Starting SSH server on port " + this.port); try { sshServer.start(); } catch (IOException e) { throw new PluginException("Unable to start SSH server on port " + this.port, e); } }
List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<>(); userAuthFactories.add(new UserAuthPassword.Factory()); sshServer.setUserAuthFactories(userAuthFactories); sshServer.setPasswordAuthenticator(new PasswordAuthenticator() { @Override
sshd.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList( new UserAuthPublicKey.Factory() ,new UserAuthPassword.Factory()));
sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) ); sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) );
sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) ); sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) );
/** * Starts a ssh server on the provided port. * * @param server the server mock to start * * @return the server. * @throws IOException if so. */ public static SshServer startServer(SshdServerMock server) throws IOException { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(0); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); List<NamedFactory<UserAuth>>userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new UserAuthNone.Factory()); sshd.setUserAuthFactories(userAuthFactories); sshd.setCommandFactory(server); sshd.start(); return sshd; }