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(); } }
server.start(); localPort = server.getPort(); log.log(Level.INFO, "CRaSSHD started on port " + localPort);
public static void main(String[] args) throws Exception { ... SshServer sshd = SshServer.setUpDefaultServer(); ... sshd.start(); Thread.sleep(Long.MAX_VALUE); }
@Override public void start() { try { sshd.start(); } catch (IOException e) { throw new RuntimeException("Could not start the server", e); } }
/** * Start the sshd. * <p/> * The ssh will normally be started by JUnit using the before() method. This method allows the sshd to * be started manually to support advanced testing scenarios. */ public void start() { try { sshd.start(); } catch (IOException e) { log.error("Unable to start ssdh.", e); throw new RuntimeException(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); } }
@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); } }
public boolean start() { if (!started) { passwordAuth.password = RandomHelper.randomString(28); port = STARTPORT; while (!started) { try { sshd.setPort(port); sshd.start(); started = true; } catch (Exception e) { e.printStackTrace(); port++; if (port >= ENDPORT) { port = -1; Log.e("SftpServer", "No more ports available"); return false; } } } } return true; }
public void start() throws IOException { LaunchingMessageKind.ISSH0001.format(this.port); try { sshd.start(); this.started=true; LaunchingMessageKind.ISSH0002.format(this.port); } catch (Exception e) { // Do nothing LaunchingMessageKind.ESSH0001.format(e); } }
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 PEMGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".pem") .getPath())); } else { sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".ser") .getPath())); } sshServer.setShellFactory(new CrestComandsFactory(session, securityHandler)); sshServer.setPasswordAuthenticator(new PasswordAuthenticatorImpl(securityHandler)); try { sshServer.start(); } catch (IOException e) { e.printStackTrace(); } }
sshServer.setSubsystemFactories(namedFactoryList); try { sshServer.start(); } catch (IOException ex) { Logger.getLogger(CarrierSFTPServer.class.getName()).log(Level.SEVERE, null, ex);
sshd.start(); } catch (IOException e) { e.printStackTrace();
public void startSSHServer() { int port = 8888; SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(port); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider( "src/test/resources/hostkey.ser")); sshd.setSubsystemFactories(Arrays .<NamedFactory<Command>> asList(new SftpSubsystem.Factory())); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setShellFactory(new ProcessShellFactory(new String[] { "/system/bin/sh", "-i", "-l" })); // necessary if you want to type commands over ssh sshd.setPasswordAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(String u, String p, ServerSession s) { return ("sftptest".equals(u) && "sftptest".equals(p)); } }); try { sshd.start(); } catch (IOException e) { e.printStackTrace(); } }
server.start(); localPort = server.getPort(); log.log(Level.INFO, "CRaSSHD started on port " + localPort);
server.start(); localPort = server.getPort(); log.log(Level.INFO, "CRaSSHD started on port " + localPort);
@BeforeClass public static void createServer() throws Exception { server = SshServer.setUpDefaultServer(); server.setPasswordAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, org.apache.sshd.server.session.ServerSession session) { return true; } }); server.setPort(port); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); SftpSubsystem.Factory sftp = new SftpSubsystem.Factory(); server.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(sftp)); server.setFileSystemFactory(new NativeFileSystemFactory() { @Override public FileSystemView createFileSystemView(org.apache.sshd.common.Session session) { return new NativeFileSystemView(session.getUsername(), false) { @Override public String getVirtualUserDir() { return remoteTemporaryFolder.getRoot().getAbsolutePath(); } }; } }); server.start(); }
sshd.start(); this.port = sshd.getPort(); return this.port;
/** * 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; }
@Override protected void startServer(PrintJid out, RP rp) throws Exception { registerSshServers(); out.println("ssh port: " + sshPort()); sshd = SshServer.setUpDefaultServer(); sshd.setPasswordAuthenticator(node().passwordAuthenticator()); sshd.setPort(sshPort()); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); setShellFactory(); sshd.start(); super.startServer(out, rp); }
Server.start();