An attempt to implement PublicKey authentication for the SFTP test server using Apache Mina. However, the Authenticate method is not called

I am using SSHD Apache Mina to implement a test SFTPServer. I was able to get everything working for simple password authentication, however I cannot configure things for PublicKey authentication. I implemented the PublickeyAuthenticator interface as follows:

public class SimpleKeyAuthenticator implements PublickeyAuthenticator {

    @Override
    public boolean authenticate(String username, PublicKey key, ServerSession session) {
        System.out.println("In authenticate");
        return false;
    }

}

My server implementation is as follows:

...
sshd = SshServer.setUpDefaultServer();


sshd.setPort(2222);
//sshd.setPort(config.getSFTPPort());

//sshd.setKeyPairProvider(new 
sshd.setKeyPairProvider(new PEMGeneratorHostKeyProvider("hostkey.pem"));
//sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());

sshd.setPublickeyAuthenticator(new SimpleKeyAuthenticator());
sshd.setFileSystemFactory(new SimpleFileSystemFactory());

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);

sshd.setSessionFactory(new SimpleSessionFactory(handler));
try {
    sshd.start();
} catch (Exception e) {
    e.printStackTrace();
}

, , SFTP-, . , , false. KeyPairProvider PEMGeneratorHostKeyProvider, SimpleGeneratorHostKeyProvider. PublicKeyAuthenticator SimpleKeyAuthenticator. : , "In authenticate", , Authenticate . - , ? .

,

+5
1

// - .

userAuthFactories.add( UserAuthNone.Factory());

:

userAuthFactories.add( UserAuthPublicKey.Factory());

+2

All Articles