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.setKeyPairProvider(new PEMGeneratorHostKeyProvider("hostkey.pem"));
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 . - , ? .
,