Java Code Examples for org.apache.sshd.SshServer#setCommandFactory()
The following examples show how to use
org.apache.sshd.SshServer#setCommandFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SftpServer.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: SshdServerMock.java From gerrit-events with MIT License | 5 votes |
/** * Starts a ssh server on the provided port. * * @param port the port to listen to. * @param server the server mock to start * * @return the server. * @throws IOException if so. */ public static SshServer startServer(int port, SshdServerMock server) throws IOException { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(port); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() { @Override public boolean authenticate(String s, PublicKey publicKey, ServerSession serverSession) { return true; } }); sshd.setCommandFactory(server); sshd.start(); return sshd; }