org.apache.sshd.server.PublickeyAuthenticator Java Examples

The following examples show how to use org.apache.sshd.server.PublickeyAuthenticator. 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: SshdServerMock.java    From gerrit-events with MIT License 5 votes vote down vote up
/**
 * 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;
}